簡體   English   中英

如何在此SQL查詢中獲取值大於3分鍾的行?

[英]How to get the rows that has the value above 3 minutes in this SQL query?

如何在此查詢中使Diff_In_Secs高於180秒?

select trunc(a.RECEIVED_TS) day, 
       to_char(avg(extract(minute from b.RECEIVED_TS - a.RECEIVED_TS)*60 + extract(second from b.RECEIVED_TS - a.RECEIVED_TS)), '999.99') Diff_In_Secs, 
       count(*)
  from nps_request a, 
       nps_reply b
 where a.id = b.ID
   and a.RECEIVED_TS > trunc(sysdate) - 10
   and b.target_id is not null
   and b.RECEIVED_TS is not null
group by trunc(a.RECEIVED_TS)
order by trunc(a.RECEIVED_TS) desc;

用選擇符包裝查詢:

SELECT * FROM ( 
    select trunc(a.RECEIVED_TS) day, to_char(avg(extract(minute from b.RECEIVED_TS - a.RECEIVED_TS)*60 + extract(second from b.RECEIVED_TS - a.RECEIVED_TS)), '999.99') Diff_In_Secs, count(*)
    from nps_request a, nps_reply b
    where a.id = b.ID
    and a.RECEIVED_TS > trunc(sysdate) - 10
    and b.target_id is not null
    and b.RECEIVED_TS is not null
    group by trunc(a.RECEIVED_TS)
    order by trunc(a.RECEIVED_TS) desc;
) AS A WHERE A.Diff_In_Secs > 180

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM