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.

 All Forums
 Other Forums
 SQL Server 6.5 \ SQL Server 7.0
 add item manually to a select distinct statement

Author  Topic 

BillEdd
Starting Member

12 Posts

Posted - 2011-09-28 : 09:46:13
I need to add an item manually to the results of a select distinct statement. My statement is:

select distinct Region from mytable order by Region

This returns:
East
North
South
West

I need to return:
Select a region
East
North
South
West

This is populating a drop down on a web site and I want "Select a region" as the first item before the regions appear

TIA

Bill

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-09-28 : 09:54:48
select ' Select a region' as Region
union all
select distinct Region from mytable order by Region




No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-09-28 : 09:56:14
Have a look: there is a space to get the ' Select a region' in top position...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -