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 |
|
snufse
Constraint Violating Yak Guru
469 Posts |
Posted - 2009-02-17 : 07:52:20
|
| I have a sales table that contains following fields:Period_Month, Period_Year, Amount and BOL (bill of lading).I need to build a query that does a couple of things:Gives me the record count by Period_Year and Period_Monthand also gives me the the total amount by Period_Year and Period_Month.My question is: Do I have to build 2 separate queries? Thank you. |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 08:12:09
|
| select count(*) as [count],sum(amount) as totalamount from urtablegroup by Period_Month, Period_Year |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-02-17 : 08:15:10
|
| For clarityselect Period_Month, Period_Year,count(*) as [count],sum(amount) as totalamount from urtablegroup by Period_Month, Period_YearMadhivananFailing to plan is Planning to fail |
 |
|
|
snufse
Constraint Violating Yak Guru
469 Posts |
Posted - 2009-02-17 : 09:54:43
|
| Thank you guys, worked purrrfectly! |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-17 : 23:41:57
|
quote: Originally posted by snufse Thank you guys, worked purrrfectly!
welcome |
 |
|
|
|
|
|