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 |
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2008-09-04 : 13:47:29
|
| suppose i have query like this:Select id,startdate,enddate,sum(days)from tablegroup by id,startdate,enddateHow can i group by :datediff(month,startdate,enddate)=3I want sum for quarterly(between startdate and enddate)Thanks. |
|
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2008-09-04 : 14:21:54
|
| Anyone? |
 |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2008-09-04 : 14:22:07
|
| Can you clarify your request? A date difference of three is a condition; not a value. Perhaps some sample data.=======================================It is impossible to imagine Goethe or Beethoven being good at billiards or golf. -H.L. Mencken, writer, editor, and critic (1880-1956) |
 |
|
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2008-09-04 : 14:22:59
|
| I want sum(days) to be group by quarterly. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-04 : 14:27:36
|
quote: Originally posted by SCHEMA I want sum(days) to be group by quarterly.
do you meant this?SELECT id,DATEADD(q,DATEDIFF(q,0,startdate),0),sum(days)FROM tableGROUP BY id,DATEADD(q,DATEDIFF(q,0,startdate),0) |
 |
|
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2008-09-04 : 14:33:20
|
| Thanks Visakh!!! Great. |
 |
|
|
|
|
|
|
|