Thursday, March 8, 2012

cascaded select

Hello,

how to do a select ... from select in MSSQL similar to Oracle? eg.

select hour
from (
select substring( daily, 9,2 ) as hour
from daytab
where userid = 12
)

results in "incorrect syntax near ')'"

thank you and regards
MarkHello, Mark

In SQL Server (and in ANSI SQL-92), the derived tables (subqueries used
in the FROM clause) need an alias:

select hour
from (
select substring( daily, 9,2 ) as hour
from daytab
where userid = 12
) A

Razvan|||Thanks a lot !!!
working for several month only with oracle made me totally forgot that.
regards
Mark

"Razvan Socol" <rsocol@.gmail.com> schrieb im Newsbeitrag
news:1120295724.860959.260300@.z14g2000cwz.googlegr oups.com...
> Hello, Mark
> In SQL Server (and in ANSI SQL-92), the derived tables (subqueries used
> in the FROM clause) need an alias:
> select hour
> from (
> select substring( daily, 9,2 ) as hour
> from daytab
> where userid = 12
> ) A
> Razvan

No comments:

Post a Comment