Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Do you see why projection doesn't work here?
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Do you see why projection doesn't work here?
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01326684
Message ID:
01326684
Vues:
72
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform