开发者

Union of two queries with the first query resultset getting the first ten rownums in Oracle

I want Union of two queries with the first query resultset getting the开发者_运维问答 first ten rownums in Oracle. Example: Like if first query has 10 rows and max rownum is 10.I want second query rownum to be started from 11 in the result of union.


SELECT  *
FROM    (
        SELECT  *
        FROM    table1
        ORDER BY
                col1
        )
WHERE   rownum <= 10
UNION ALL
SELECT  *
FROM    (
        SELECT  *, rownum AS rn
        FROM    (
                SELECT  *
                FROM    table2
                ORDER BY
                        col2
                )
        )
WHERE   rn > 10
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜