Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Do you see why projection doesn't work here?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01326684
Message ID:
01326686
Views:
19
>Hi everybody,
>
>I have a complex (and wrong) select statement that I tried yesterday at home (where I have an empty database with the same structure) and this query produced an error.
>
>SELECT P.PersonID, P.FirstName, P.MiddleName, P.LastName, P.Gender,
>P.DOB,
>( select top 1  Address1 from people where personid=P.father ) as FAddress ,
>  ( select top 1  Address1 from people where personid=P.mother ) as MAddress ,
>(select  case ( select top 1  CellPhone from people where personid=P.father) when '' then '-' else
>( select top 1  CellPhone from people where personid=P.father) end) as FCellPhone ,
>(select case ( select top 1 CellPhone from people where personid=P.mother ) when ''
>then '-' else ( select top 1 CellPhone from people where personid=P.mother ) end) as MCellPhone
, etc.
>
>I tried this select again here and it worked just fine.
>
>The only difference that I don't have data at home.
>
>In any case, the select statement is wrong, so I would be changing it... But just curiosity sake why didn't it work without data?
>
>Thanks again.


And the error is?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform