Author |
Topic |
john20
Starting Member
30 Posts |
Posted - 2008-04-09 : 07:56:50
|
Hi All,I want to sort the column data which is of positive and negative number like the following.-5823-1200100i want to sort like-1100200-5823How can i do that can any one help me..Thanks in advance.-john |
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-04-09 : 08:03:42
|
select * from table order by abs(x)Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
|
|
john20
Starting Member
30 Posts |
Posted - 2008-04-09 : 08:07:11
|
Hi Thanks for ur reply...Tried the above solution but this only giving same result means-5823-1200100 i want -1100200-5823Regards,-john |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-09 : 08:13:42
|
Works for everyone else...DECLARE @Sample TABLE (i INT)INSERT @SampleSELECT -5823 UNION ALLSELECT -1 UNION ALLSELECT 200 UNION ALLSELECT 100SELECT *FROM @SampleORDER BY ABS(i) E 12°55'05.25"N 56°04'39.16" |
|
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-04-09 : 08:14:54
|
quote: Originally posted by john20 Hi Thanks for ur reply...Tried the above solution but this only giving same result means-5823-1200100 i want -1100200-5823Regards,-john
Give your queryPrakash.PThe secret to creativity is knowing how to hide your sources! |
|
|
john20
Starting Member
30 Posts |
Posted - 2008-04-09 : 09:14:31
|
My Qyery is :Select id from users order by id |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-09 : 09:15:18
|
quote: Originally posted by john20 My Qyery is :Select id from users order by id
Why don't you run the query given to you by Ryan and me?Select id from users order by ABS(id) E 12°55'05.25"N 56°04'39.16" |
|
|
john20
Starting Member
30 Posts |
Posted - 2008-04-09 : 09:23:32
|
Hi All ,Thanks its working now.....Cheers |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-09 : 09:26:33
|
quote: Originally posted by john20 Hi All ,Thanks its working now.....Cheers
Please read the replies carefully MadhivananFailing to plan is Planning to fail |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-09 : 09:27:47
|
quote: Originally posted by RyanRandall select * from table order by abs(x)Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part.
RyanRandall, nice to see you here after a long time MadhivananFailing to plan is Planning to fail |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2008-04-09 : 09:52:20
|
quote: RyanRandall, nice to see you here after a long time MadhivananFailing to plan is Planning to fail
Hi MadhiJust passing through... I see you and Peso are still prolific!Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part. |
|
|
|