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 |
mahender
Starting Member
12 Posts |
Posted - 2010-07-16 : 09:04:46
|
need help !!!have a table TAB1name | mark1 | mark2 | mark3 John | 90 | 60 | 60Mike | 30 | 40 | 30Andy | 30 | 20 | 70Total| 150 | 120 | 160---------------------------the dificlty is that i can need the TOTAL row at the bottom as seen above and need the names in asc order.Currently i can do only one instance either asc order or make the TOTAL at the bottom . How can i do both same query ??? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-07-16 : 09:16:50
|
ORDER BY case when name = 'Total' then 2 else 1 end, name KH[spoiler]Time is always against us[/spoiler] |
 |
|
mahender
Starting Member
12 Posts |
Posted - 2010-07-16 : 09:46:44
|
hey i am sorry for this alteration in the problem.. i have used two select statements one for the selection of records another for the total (one row) .these two are then made UNION and the result is displayd .. pls help me |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-16 : 10:03:49
|
select * from(your_first_selectUNIONyour_second_select)dtORDER BY case when name = 'Total' then 2 else 1 end, name No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
mahender
Starting Member
12 Posts |
Posted - 2010-07-16 : 10:27:49
|
Thanks a lot !!! i got it !!! |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-16 : 10:37:16
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-07-16 : 11:56:41
|
quote: Originally posted by mahender need help !!!have a table TAB1name | mark1 | mark2 | mark3 John | 90 | 60 | 60Mike | 30 | 40 | 30Andy | 30 | 20 | 70Total| 150 | 120 | 160---------------------------the dificlty is that i can need the TOTAL row at the bottom as seen above and need the names in asc order.Currently i can do only one instance either asc order or make the TOTAL at the bottom . How can i do both same query ???
If you use reporting tool, do this aggregation thereMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|