Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL How to?
Message
De
15/08/2007 16:26:23
 
 
À
15/08/2007 14:33:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01248319
Message ID:
01248361
Vues:
20
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform