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 |
|
shantanu88d
Starting Member
35 Posts |
Posted - 2011-04-21 : 01:41:36
|
I have a tablecarrier--------------AircelAirtelVodafoneVirgin MobilesUninorIdeaDocomoMTSMTNLBSNLDolphinI want to populate a dropdownList with these carriers, however i want another element ---Select--- to appear above them. I triedSELECT '---SELECT---'UNIONSELECT * FROM carriers This works. But carriers are not in order. When I do thisSELECT '---SELECT---'UNIONSELECT * FROM carriersORDER BY carrier I get error: ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator.How to order these elements and include ---SELECT--- at the top of them using a query.Plz help !!! |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-21 : 02:02:39
|
This should work:select * from(SELECT '---SELECT---' as itemUNIONSELECT * FROM carriers)dtorder by case when item = '---SELECT---' then char(32) else item end No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
shantanu88d
Starting Member
35 Posts |
Posted - 2011-04-21 : 03:33:51
|
| Amazing...that was really great. I hope one day I will reach to your knowledge level !! :) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-04-21 : 03:40:20
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|