Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL How to?
Message
From
15/08/2007 16:26:23
 
 
To
15/08/2007 14:33:12
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01248319
Message ID:
01248361
Views:
19
You probably could do this in one pass as Naomi is suggesting, but chances are it's much faster to do it in the two statements as you have it.

>The following two SQL statements are giving me the correct record set. My question is there a way I can do this with one statement? Is there a better way to do this?
>
>
>
>SELECT item, descrip, extprice, invdte, YEAR(invdte) as invyear FROM artran99 UNION ALL select item, descrip, extprice, invdte, YEAR(invdte) as invyear FROM arytrn99 ORDER BY item INTO TABLE invdata
>
>
>SELECT item, descrip, SUM(IIF(invyear = YEAR(DATE()),extprice,0)) as CurrentYear, SUM(IIF(invyear = YEAR(DATE())-1,extprice,0)) as OneYearAgo, SUM(IIF(invyear = YEAR(DATE())-2,extprice,0)) as TwoYearsAgo, SUM(extprice) as YTDTotal FROM invdata GROUP BY item,descrip
>
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Previous
Reply
Map
View

Click here to load this message in the networking platform