2012-10-18 38 views

回答

1

您可以使用ROWNUM在Oracle中。点击Here的文档

select * 
from 
    (select * 
    from your_table 
    where cust_id=<given cust_id> 
    order by lastUpdatedDate desc) 
where ROWNUM <= 10; 
0

Oracle支持ROW_NUMBER()和窗函数。请尝试以下,

SELECT act_id, cust_id, lastUpdatedDate, custActivity 
FROM 
(
    SELECT act_id, cust_id, lastUpdatedDate, custActivity, 
      ROW_NUMBER() OVER (PARTITION BY cust_id ORDER BY lastUpdatedDate DESC) rn 
    FROM tableNAME 
) x 
WHERE rn <= 10 
0

希望这会有助于你 -

select act_id,cust_id,lastUpdatedDate,custActivity 
    from (
    select act_id,cust_id,lastUpdatedDate,custActivity, row_number() over (order by lastUpdatedDate) r 
     from abc 
    where act_id=<cust_id> 
) 
where r between 1 and 10;