Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select with Sales by Month
Message
 
 
To
16/10/2005 13:41:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01059504
Message ID:
01059510
Views:
7
>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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform