filter the data in time basis in oracle
below mentioned qry only am using to filter the data in time basis. am having a little bit doubt in that. for e.g. for 01AM i ll get the 8 records but it should have 7 records. bcoz 2 columns repeated. if i use count seperately it ll give write ans. can u plz help me..
SELECT TRUNC(createdon,'hh'), SUM(CASE WHEN hh=1 THEN 1 ELSE 0) h1,
开发者_JAVA百科 SUM(CASE WHEN hh=2 THEN 1 ELSE 0) h2 .....
FROM TABLle1,
(SELECT 1 AS hh FROM dual
UNION
SELECT 2 AS hh FROM dual
UNION
SELECT 3 AS hh FROM dual
....
) hours
WHERE LABSTATUS=1 AND CREATEDON >=TO_DATE('01/07/2010 10','DD/MM/YYYY hh') AND
TRUNC(createdon,'hh')= hours.hh
GROUP BY TRUNC(createdon,'hh')
You might want to use HH24 instead of HH.
精彩评论