Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Do you see why projection doesn't work here?
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Do you see why projection doesn't work here?
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01326684
Message ID:
01326684
Views:
71
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.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform