|
--解决方案3 --利用UNION 运算符 select * from ai where no='4' union all select * from ai where no='1' union all select * from ai where no='2'
ii. --查询要求指定no='4'排第一行,其他的行随机排序 id no ----------- ---------- 105 4 105 2 105 1 103 1
--解决方案 select * from ai order by case when no='4' then 1 else 1+rand() end
iii. --查询要求所有行随机排序
--解决方案 select * from ai order by newid()
iiii --有一表ab有列i,其中数据如下: i varchar(10) a1 a10 a101 a5 p4 p41 p5
--现在要求列i中数据先按字母排序,再按数字排序 --效果如下: a1 a5 a10 a101 p4 p5 p41
--解决方案 select * from ab order by left(i,1),convert(int,substring(i,2,8000)) 上一页 [1] [2] |