Tuesday, July 10, 2012

DB2 : Select Current Month Records

Example:

SELECT Count(EL.SCREEN_MODULE_NAME) as ESH_NOOFHITS_CM,AT.DATE_TIME as ESH_TIMESTAMP_CM
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
days(AT.DATE_TIME) between days(CURRENT TIMESTAMP)-34 AND days(CURRENT TIMESTAMP) AND Year(CURRENT TIMESTAMP)=Year(AT.DATE_TIME) 
GROUP BY AT.DATE_TIME
ORDER BY DATE(AT.DATE_TIME) ;

No comments:

Post a Comment