Tuesday, July 10, 2012

DB2 : Select Last 7 days

Example: 
SELECT Count(EL.SCREEN_MODULE_NAME) as ESH_NOOFHITS_WEEK,AT.DATE_TIME as ESH_TIMESTAMP_WEEK
FROM AUDT.TBL_AUDIT_TRAIL_SYSTEM AT ,ESERVICES_LIST EL
WHERE 
RTRIM(AT.SCREEN_MODULE_NAME) LIKE  '%'  CONCAT RTRIM( EL.SCREEN_MODULE_NAME) CONCAT '%'  AND
YEAR(AT.DATE_TIME)=YEAR(CURRENT TIMESTAMP) AND
days(AT.DATE_TIME) between days(CURRENT TIMESTAMP)-6 AND days(CURRENT TIMESTAMP) 
GROUP BY AT.DATE_TIME
ORDER BY DATE(AT.DATE_TIME) ;

No comments:

Post a Comment