一个表中的内容如:字段a,字段b,字段c,字段d
abc, def, a , 3
123,34, b , 2
要求查询出来显示为:字段a,字段b,字段c,字段d
abc, def, a1, 3
abc, def, a2, 3
abc, def, a3, 3
123, 34, b1, 2
123, 34, b2, 2
即:字段d的数字是多少,该条记录就显示几条,且字段c显示为'字段c'+n
abc, def, a , 3
123,34, b , 2
要求查询出来显示为:字段a,字段b,字段c,字段d
abc, def, a1, 3
abc, def, a2, 3
abc, def, a3, 3
123, 34, b1, 2
123, 34, b2, 2
即:字段d的数字是多少,该条记录就显示几条,且字段c显示为'字段c'+n
select a.字段a,a.字段b,a.字段c+ltrim(b.number) as 字段c,a.字段d
from tb a,master..spt_values b
where b.[type] = 'p' and b.number between 1 and a.字段d
from tb a,master..spt_values b
where b.type='p' and b.number<a.字段d
from tb a,master..spt_values b
where b.type='p' and b.number<a.字段d
a.字段a,a.字段b,a.字段c+ltrim(b.number) as 字段c,a.字段d
from
tb a,master..spt_values b
where
b.[type] = 'p'
and
b.number between 1 and a.字段d