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 |
gsrinivas.
Yak Posting Veteran
56 Posts |
Posted - 2012-10-26 : 14:05:42
|
Hi team,I have an issue with order by clause..plz suggest me the best query..Thanks in advance...-Srinivas.-----------************************************-------------- INPUT-----------************************************--------------CREATE TABLE T ( C1 VARCHAR(20),C2 VARCHAR(20))INSERT INTO T VALUES ('ALFABET','A')INSERT INTO T VALUES ('ALFABET','B')INSERT INTO T VALUES ('ALFABET','C')INSERT INTO T VALUES ('NUBER','1')INSERT INTO T VALUES ('NUBER','2')INSERT INTO T VALUES ('NUBER','3')INSERT INTO T VALUES ('NUBER','4')INSERT INTO T VALUES ('SYMBOL','+')INSERT INTO T VALUES ('SYMBOL','-')-----------************************************-------------- OUTPUT-----------************************************--------------Now the output should be as follows...NUBER 1NUBER 2NUBER 3NUBER 4ALFABET AALFABET BALFABET CSYMBOL +SYMBOL - |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2012-10-26 : 14:14:22
|
SELECT * FROM TORDER BY CASE WHEN C2 LIKE '%[0-9]' THEN 0 ELSE 1 END,CASE WHEN C2 LIKE '%[A-Z]' THEN 0 ELSE 1 END,CASE WHEN C2 LIKE '%[^0-9A-Z]' THEN 0 ELSE 1 END,C2 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|