Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DB2 in SSRS

Status
Not open for further replies.

db2mo

Programmer
Mar 29, 2011
4
US
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.
 
Keep your year parameters. Set the default of the parameters (not in the query) to =YEAR(NOW()) and =YEAR(NOW()) - 2
 
I'll give that a try. Thanks for the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top