我想也许是这样,但是这样的结果是先取五条记录然后排序~~~~~~~~-_-
SELECT TOP 5 HOSPITAL..MZ_SJH.SJH
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc
如何做到先将整个标的记录按字段排序,然后再取top5呢?
4 个解决方案
#1
用top是不支持ORDER的。
只能用游标。
或在数据窗口中,只检索5条。
只能用游标。
或在数据窗口中,只检索5条。
#2
select * from ( SELECT TOP 5 HOSPITAL..MZ_SJH.SJH
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc) aa where.....
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc) aa where.....
#3
select * from
(
SELECT TOP 5 HOSPITAL..MZ_SJH.SJH
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc
)
where rownum<=5
#4
同意liuwenbo_wenbo(菜鸟)
#1
用top是不支持ORDER的。
只能用游标。
或在数据窗口中,只检索5条。
只能用游标。
或在数据窗口中,只检索5条。
#2
select * from ( SELECT TOP 5 HOSPITAL..MZ_SJH.SJH
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc) aa where.....
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc) aa where.....
#3
select * from
(
SELECT TOP 5 HOSPITAL..MZ_SJH.SJH
FROM HOSPITAL..MZ_SJH
ORDER BY HOSPITAL..MZ_SJH.SJH asc
)
where rownum<=5
#4
同意liuwenbo_wenbo(菜鸟)