2012-02-21 8 views
0

このクエリで180秒以上のDiff_In_Secsを取得する方法はありますか?このSQLクエリで3分以上の値を持つ行を取得する方法はありますか?

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; 

答えて

1

ラップを選択して、クエリ:

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 
関連する問題