如何用一条SQL查出一列值为1~12的升序数
sql吧
全部回复
仅看楼主
level 1
meteor104 楼主
如何用一条SQL查出一列值为1~12的升序数?内容如:----------------yuefen123456789101112------------
2008年09月25日 04点09分 1
level 1
meteor104 楼主
没有现成的数据表的情况下。用什么样的内部方法可以解决?
2008年11月06日 06点11分 3
level 0
select 1 as 'yuefen'unionselect 2unionselect 3...unionselect 12
2008年11月06日 07点11分 4
level 4
二楼的查询结果,无法避免有重复的值啊
2008年11月06日 12点11分 5
level 5
--测试数据declare @tab table(yuefen int)insert @tabselect '0' union allselect '1' union allselect '3' union allselect '2' union allselect '2' union allselect '3' union allselect '4' union allselect '5' union allselect '6' union allselect '6' union allselect '7' union allselect '9' union allselect '8' union allselect '9' union allselect '10' union allselect '13' union allselect '12' union allselect '14' union allselect '11' union allselect '15' union allselect '12';--select * from @tab--测试代码select distinct * from @tab where yuefen >0 and yuefen<13 order by yuefen/* 测试结果(所影响的行数为 21 行)yuefen ----------- 123456789101112(所影响的行数为 12 行)*/
2008年11月07日 04点11分 6
level 5
顶6楼!!!
2008年11月10日 08点11分 7
level 1
[滑稽]4楼的方法不错
2018年04月30日 17点04分 8
1