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 |
|
pentahari
Starting Member
26 Posts |
Posted - 2008-08-26 : 03:56:01
|
| how to use sorting in group by. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-26 : 04:00:14
|
| sorting is done by using order by |
 |
|
|
pentahari
Starting Member
26 Posts |
Posted - 2008-08-26 : 04:04:06
|
quote: Originally posted by visakh16 sorting is done by using order by
My query is:select dateadd(month, datediff(month, 0, voucher.vou_date), 0) as a from voucher where vou_date>='6/26/2007' and vou_date<'8/27/2008' group by dateadd(month, datediff(month, 0, voucher.vou_date), 0) The above query's result is not sorting.Thanks Advance,PentaHari |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-08-26 : 04:12:52
|
quote: Originally posted by pentahari
quote: Originally posted by visakh16 sorting is done by using order by
My query is:select dateadd(month, datediff(month, 0, voucher.vou_date), 0) as a from voucher where vou_date>='6/26/2007' and vou_date<'8/27/2008' group by dateadd(month, datediff(month, 0, voucher.vou_date), 0) order by dateadd(month, datediff(month, 0, voucher.vou_date), 0) The above query's result is not sorting.Thanks Advance,PentaHari
Where is order by as suggested by Visakh.Add order by to your query. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-26 : 04:13:19
|
| How do you expect it to sort when you've not specified any specific order for sorting by using order by? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-26 : 04:16:05
|
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-26 : 04:16:36
|
| select dateadd(month, datediff(month, 0, voucher.vou_date), 0) as a from voucher where vou_date>='6/26/2007' and vou_date<'8/27/2008' group by dateadd(month, datediff(month, 0, voucher.vou_date), 0) order by aMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|