如何修改此查询以便我在rownum 10和21之间获得结果,例如:
SELECT DAL_ROWNOTABLE.DAL_ID
FROM (SELECT ticket.id AS "DAL_ID"
FROM ticket_table ticket
WHERE (ticket.type = N'I' ) AND
(ticket.tenant IS NULL OR
ticket.tenant IN (SELECT tgm.tenant_id
FROM tenant_group_member tgm
WHERE tgm.tenant_group = HEXTORAW('30B0716FEB5F4E4BB82A7B7AA3A1A42C')
)
)
ORDER BY ticket.id
) DAL_ROWNOTABLE
WHERE rownum <= 21;
任何帮助将不胜感激。
答案 0 :(得分:0)
将rownum
更改为row_number()
:
SELECT DAL_ROWNOTABLE.DAL_ID
FROM (SELECT ticket.id AS "DAL_ID",row_number() over (order by ticket_id) as seqnum
FROM ticket_table ticket
WHERE (ticket.type = N'I' )AND
(ticket.tenant IS NULL OR
ticket.tenant IN(SELECT tgm.tenant_id
FROM tenant_group_member tgm
WHERE tgm.tenant_group = HEXTORAW('30B0716FEB5F4E4BB82A7B7AA3A1A42C')
)
)
) DAL_ROWNOTABLE
WHERE seqnum between 10 and 21;