Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Simple (hopefully) question.

Author  Topic 

RSRS
Starting Member

2 Posts

Posted - 2004-02-24 : 09:02:36
I have a large table of sales detail e.g.:
Cust1 | 22-dec | 99.95
Cust2 | 23-dec | 2.99
Cust2 | 23-dec | 140.00
Cust2 | 23-dec | 100.00
....

and I want to output a report table grouped by cust/date such as:
CustName | Date | TotalSales | Sales<10 | Sales<100 | OtherSales
Cust1 | 22-d | 99.95 | 0 | 99.95 | 0
Cust2 | 23-d | 242.99 | 2.99 | 240.00 | 0
...

Obviously this can be done by joining multiple queries, but is there a single query way around this?
TIA for any help.

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-02-24 : 09:04:42
Investigate the CASE statement....search here for examples (use CASE + SUM as keywords)...there are some good recent simple examples that will get you moving in the right direction.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-02-24 : 09:10:17
Isn't

Sales<100

Really

10>Sales<100



Brett

8-)
Go to Top of Page

RSRS
Starting Member

2 Posts

Posted - 2004-02-24 : 09:41:45
Sorted now. Thanks for the pointer!
Go to Top of Page
   

- Advertisement -