Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select with Sales by Month
Message
 
 
À
16/10/2005 13:41:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01059504
Message ID:
01059510
Vues:
8
>Hi all
>
>I need to make a SQL statement to retrive the month sales for all customers filtered by start date and end date (Ex: Start: 2005-01-01 End 2005-12-31).
>
>
So i need customer 0001 sales January, february, etc...
>                   0002 sales january, march, etc.
>
>Any smart aproach to do that.
>

You can SELECT with GROUP BY 'customer' and 'MONTH(SaleDate)' and use one of Crosstab utilities available. Or
SELECT Customer, ;
  SUM(IIF(MONTH(SaleDate)=1, Ammount, 0000000.00) AS Jan, ;
  SUM(IIF(MONTH(SaleDate)=2, Ammount, 0000000.00) AS Feb, ;
  SUM(IIF(MONTH(SaleDate)=3, Ammount, 0000000.00) AS Mar, ;
...
  SUM(IIF(MONTH(SaleDate)=12, Ammount, 0000000.00) AS Dec, ;
...
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform