我有这张桌子
select
Store_Desc + ' ('+Store_ID + ')' as storename
from
table_name
order by
ID
结果:
Apple (0051)
Cherries (0060)
Banana (0081)
在结果的顶部,我需要另一行看起来像:
结果:
Fruits
----------------
Apple (0051)
Cherries (0060)
Banana (0081)
如何在不改变顺序的情况下插入顶行(我可以根据需要使用临时表)
答案 0 :(得分:2)
除非你使用临时表,否则需要重复ID
foreach/2
或
select Store_Desc + ' (' + Store_ID +')' as storename, ID
from table_name
union all
select 'fruit', '0'
order BY ID