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 |
|
Sandor
Starting Member
2 Posts |
Posted - 2012-08-22 : 16:07:00
|
| Hello,Would someone please provide assistance in completing a SQL query?I run a small business and use a SQL database to record all transactions made by my clients.This database contains the client name, transaction date and transaction amount.I would like to see the clients that have spend more than £ 100 within the past 7 days.I composed the query below with aggregate function. The query returns the client and the sum of all transactionsmade in the past seven days. So far so good, but I only want to see clients who have spend more than 100.What code do I have to add?thanks and regards,Sandor------------------Selectclient,Sum (transaction.amount)from CUSTOMER DATABASEwhere trans_dt>=today(*)-7Group by client |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-22 : 16:10:54
|
| [code]Selectclient,Sum (transaction.amount)from CUSTOMER DATABASEwhere trans_dt>=today(*)-7Group by clienthaving Sum (transaction.amount)>100[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Sandor
Starting Member
2 Posts |
Posted - 2012-08-22 : 16:21:02
|
Hello visakh16,Thanks so much for your quick reply. I will use this code tomorrow king regards,Sandor |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-22 : 18:00:02
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|