Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combine SQL Results into one record
Message
From
31/07/2013 14:00:14
 
 
To
31/07/2013 13:54:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01579549
Message ID:
01579552
Views:
32
I don't have time to work though the SQL statement, but you could get the MAX from each column.

>I have the following sql select statement :
>
>
>SELECT  SUM(IIF(division = 'Northern',1,0)) AS NODQTY, SUM(IIF(division = 'Northern',tonnage,0)) AS NODTonnage,;
>      SUM(IIF(division = 'New England',1,0)) AS NEDQTY, SUM(IIF(division = 'New England',tonnage,0)) AS NEDTonnage,;
>      SUM(IIF(division = 'Mid-Atlantic',1,0)) AS MADQTY, SUM(IIF(division = 'Mid-Atlantic',tonnage,0)) AS MADTonnage,;
>      SUM(IIF(division = 'Mid-South',1,0)) AS MSDQTY, SUM(IIF(division = 'Mid-South',tonnage,0)) AS MSDTonnage,;
>      SUM(IIF(division = 'Southern',1,0)) AS SODQTY, SUM(IIF(division = 'Southern',tonnage,0)) AS SODTonnage,;
>      SUM(IIF(division = 'Mid-West',1,0)) AS MWDQTY, SUM(IIF(division = 'Mid-West',tonnage,0)) AS MWDTonnage,;
>      SUM(IIF(division = 'North West',1,0)) AS NWDQTY, SUM(IIF(division = 'North West',tonnage,0)) AS NWDTonnage ;
>FROM curProjects  ;
>INTO CURSOR curTemp WHERE !DELETED() GROUP BY division
>
>
>
>This produces a cursor with something similar to the following:
>
>
>Nodqty  Nodtonnage   Nedqty    Nedtonnage    Madqty   Madtonnage ...
>0           0          0            0         68        25712
>0           0          20           52276      0         0
>143       540593       0            0          0         0
>
>
>
>Is there a way to construct the sql select statement so that I get one line like the following:
>
>
>Nodqty  Nodtonnage   Nedqty    Nedtonnage    Madqty   Madtonnage ...
>143     540593         20        52276        68      25712
>
>
>
>Thanks in advance,
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform