Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can not get this right
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01319440
Message ID:
01319466
Views:
13
>Hi everybody,
>
>I can not figure out how to correctly produce the following report:
>
>I have two tables: People (cID, LName, FName) and Phones (cID, Phone, Type).
>
>There are several different types of the phones (Home, Office, Cell, E-Mail and few others).
>
>I want to display the info as
>
>Person Info - group
>
>Home   Office     Cell  E-Mail (Type)
>
>
>So far all the select statements I tried produced wrong results.
>
>May be someone much clever than me can help.
>
>Thanks a lot in advance.
SELECT People.cID,;
       MAX(LName) AS LName,;
       MAX(FName) AS FName,;
       MAX(IIF(Phones.Type=='Home'  , Phone, CAST([] AS C(??))) AS Home,;
       MAX(IIF(Phones.Type=='Office', Phone, CAST([] AS C(??))) AS Office,;
       MAX(IIF(Phones.Type=='Cell'  , Phone, CAST([] AS C(??))) AS Cell,;
....
FROM People;
INNER JOIN Phones ON People.cId == Phones.cId;
GROUP BY People.cID
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