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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-08-26 : 04:13:02
|
| I have a table called customers and in the table is iddatesitenamecodeHow can I get a query per site and per quarter of the amount of tickets?then the next thing i need is i have 2 more tablespayments and cancelled that have the same namecode in it.for each record in the above query - I want the count of how many of those namecode were paid and cancelled. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-26 : 04:15:29
|
| SELECT site,DATEPART(qq,date),your aggregate fieldsFROm yourtableGROUP BY site,DATEPART(qq,date)i'm not sure what you want to aggregate for the grouping (you've not specified. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-08-26 : 05:28:55
|
| DATEPART(qq,date)how can i get this be year and quarter so i'd have1 20072 20073 20074 20071 20082 2008 etc. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-08-26 : 05:38:17
|
SELECT DATEPART(QUARTER, Col1), DATEPART(YEAR, Col1)FROM Table1GROUP BY DATEPART(QUARTER, Col1), DATEPART(YEAR, Col1)ORDER BY DATEPART(YEAR, Col1), DATEPART(QUARTER, Col1) E 12°55'05.25"N 56°04'39.16" |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2008-08-26 : 06:02:46
|
| thanks |
 |
|
|
|
|
|
|
|