-3

I have this table

select 
    Store_Desc + ' ('+Store_ID + ')' as storename  
from  
    table_name  
order by
    ID

Results:

 Apple (0051)
 Cherries (0060)
 Banana (0081)

On the top of the result I need another row looks like:

Result:

Fruits
----------------
Apple (0051)
Cherries (0060)
Banana (0081)

How should I need to insert top row with out changing order down (I can use temporary table if needed)

sravas
  • 41
  • 8

1 Answers1

3

Unless you use a temporary table would need to repeat ID

select Store_Desc + ' (' + Store_ID +')' as storename, ID  
from table_name  
union all 
select 'fruit', '0'
order BY  ID  

or

declare @T table (storename varchar(20), ID varchar(10));
insert into @T values ('fruit', '0');
insert into @T 
select select Store_Desc + ' (' + Store_ID + ')', ID  
from  table_name;
select storename 
from @T 
order by ID;
paparazzo
  • 44,497
  • 23
  • 105
  • 176