Hi,
I'm using DB2 tables to run a report in SSRS 2008. The first issue I'm having is comparing the date in my DB2 table to the system date. How would I code that? Currently the code looks like this:
SELECT CNT AS ACC_CNT, KILLED, INJURED, INCYEAR AS ACC_YR, (CASE SEVERITY WHEN '1' THEN 'Fatal' WHEN '2' THEN 'Personal Injury' WHEN '3' THEN 'Property Damage' END) AS SEV_ACC
FROM TABLE
(SELECT COUNT(QO01ACCIDENT_NO) AS CNT, SUM(QO01NUMBER_KILLED) AS KILLED, SUM(QO01NUMBER_INJURED) AS INJURED, INCYEAR, SEVERITY, GROUPING(INCYEAR) AS INCYEAR_GROUP,
GROUPING(SEVERITY) AS SEVERITY_GROUP
FROM TABLE
(SELECT QO01ACCIDENT_NO, QO01ACCIDENT_SEVERITY AS SEVERITY, QO01ACCIDENT_YEAR AS INCYEAR, QO01NUMBER_KILLED, QO01NUMBER_INJURED
FROM XTECH.TR10TBACCIDENT
WHERE (QO01ACCIDENT_YEAR BETWEEN '2008' AND '2010') AND QO01SUBMIT_AGENCY_ORI = ? OR QO01MUNICIPALITY = ?)) AS SEVACC
GROUP BY CUBE(INCYEAR, SEVERITY)
ORDER BY INCYEAR ASC, SEVERITY ASC) AS STAT WHERE (INCYEAR_GROUP = 0 AND SEVERITY_GROUP = 0)
I'm sorry, I know that's a lot of code. What I'm wanting to do is replace the "(QO01ACCIDENT_YEAR BETWEEN '2008 AND '2010') and code it to look up the current date and previos years from the system to avoid having to enter in the years each time this is ran.
I'm using DB2 tables to run a report in SSRS 2008. The first issue I'm having is comparing the date in my DB2 table to the system date. How would I code that? Currently the code looks like this:
SELECT CNT AS ACC_CNT, KILLED, INJURED, INCYEAR AS ACC_YR, (CASE SEVERITY WHEN '1' THEN 'Fatal' WHEN '2' THEN 'Personal Injury' WHEN '3' THEN 'Property Damage' END) AS SEV_ACC
FROM TABLE
(SELECT COUNT(QO01ACCIDENT_NO) AS CNT, SUM(QO01NUMBER_KILLED) AS KILLED, SUM(QO01NUMBER_INJURED) AS INJURED, INCYEAR, SEVERITY, GROUPING(INCYEAR) AS INCYEAR_GROUP,
GROUPING(SEVERITY) AS SEVERITY_GROUP
FROM TABLE
(SELECT QO01ACCIDENT_NO, QO01ACCIDENT_SEVERITY AS SEVERITY, QO01ACCIDENT_YEAR AS INCYEAR, QO01NUMBER_KILLED, QO01NUMBER_INJURED
FROM XTECH.TR10TBACCIDENT
WHERE (QO01ACCIDENT_YEAR BETWEEN '2008' AND '2010') AND QO01SUBMIT_AGENCY_ORI = ? OR QO01MUNICIPALITY = ?)) AS SEVACC
GROUP BY CUBE(INCYEAR, SEVERITY)
ORDER BY INCYEAR ASC, SEVERITY ASC) AS STAT WHERE (INCYEAR_GROUP = 0 AND SEVERITY_GROUP = 0)
I'm sorry, I know that's a lot of code. What I'm wanting to do is replace the "(QO01ACCIDENT_YEAR BETWEEN '2008 AND '2010') and code it to look up the current date and previos years from the system to avoid having to enter in the years each time this is ran.