2015-09-20 55 views
0

我試圖在Oracle執行下面的SQL語句:預言 - 爲了在子查詢

SELECT 
    a.*, b.* 
FROM 
    v$sql a, 
    v$sql_bind_capture b 
WHERE 
    b.sql_id = a.sql_id 
    AND 
    b.sql_id IN 
    (select sql_id from v$sql where rownm < 100 order by elapsed_time desc) 
ORDER BY 
    b.child_address, b.position 

錯誤代碼是「缺少右括號

我想獲得的100個語句。從v $ SQL下令ELAPSED_TIME然後afterwarts正從視圖v $ sql_bind_capture相應的後綁定。

有人可以幫助我,THX提前

回答

0

試試這個:

SELECT a.*, b.* 
FROM v$sql a, v$sql_bind_capture b 
WHERE b.sql_id = a.sql_id 
AND b.sql_id IN (SELECT * from 
(select sql_id from v$sql order by elapsed_time desc) 
WHERE rownum <=100) 
ORDER BY b.child_address, b.position 

一些更多的信息here

+0

沒關係我先前的評論,讓我吃驚的第一件事,就是這是99而不是100。 –

+0

盛衰我的錯。我已將<100'改爲<= 100' –

0
SELECT * 
FROM (SELECT * FROM (SELECT * FROM V$SQL ORDER BY ELAPSED_TIME DESC) WHERE ROWNUM <= 100) a 
     INNER JOIN 
     v$sql_bind_capture b 
     ON (b.sql_id = a.sql_id) 
ORDER BY 
     b.child_address, 
     b.position;