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.
| Author |
Topic |
|
Knarf180
Starting Member
42 Posts |
Posted - 2004-11-19 : 11:30:04
|
| I'm sure there is an easy way to do something like this but its just not hitting me today. Basically I have a bunch of records linked by a customer number. I need to find the number of customers whos total purchases are greater then $2000.Sample table:CustomerID orderNumber ItemNumber Cost1000 500 3334 3.451000 500 4324 5.221001 501 2332 4.431001 501 3494 8.99Basically it must be grouped by customer number and the sum of the cost must greater then 2000. I'm tired and its Friday.. Any advice? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-11-19 : 11:34:09
|
| SELECT CustomerID, Sum(Cost) AS Total FROM myTable GROUP BY CustomerID HAVING Sum(Cost)>2000 |
 |
|
|
Knarf180
Starting Member
42 Posts |
Posted - 2004-11-19 : 11:40:13
|
| Ahh, I love this board. Thanks much. |
 |
|
|
|
|
|