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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column in report with search case statement

Status
Not open for further replies.
Apr 4, 2005
13
US
Hi! I have many columns "0 to 7 Days", "0 to 14 day" "0 to 30 days" etc ( as shown in the following query) like this in my report. I tried to use calculation with search case statement. It does not work. It gives me lot of errors. The client database is DB2. Can anyone suggest any other way to achieve it?

DECIMAL ( ( SUM ( CASE
WHEN ( DAYSWRK BETWEEN 0 AND 7 ) THEN ( FORMCOUNT )
ELSE ( 0 )
END ) ) ) / DECIMAL ( SUM ( FORMCOUNT ) ) AS "% 0 to 7 Days",
DECIMAL ( ( SUM ( CASE
WHEN ( DAYSWRK BETWEEN 0 AND 10 ) THEN ( FORMCOUNT )
ELSE ( 0 )
END ) ) ) / DECIMAL ( SUM ( FORMCOUNT ) ) AS COLUMN0015,
DECIMAL ( ( SUM ( CASE
WHEN ( DAYSWRK BETWEEN 0 AND 14 ) THEN ( FORMCOUNT )
ELSE ( 0 )
END ) ) ) / DECIMAL ( SUM ( FORMCOUNT ) ) AS "% 0 to 14 Days",
DECIMAL ( ( SUM ( CASE
WHEN ( DAYSWRK BETWEEN 0 AND 15 ) THEN ( FORMCOUNT )
ELSE ( 0 )
END ) ) ) / DECIMAL ( SUM ( FORMCOUNT ) ) AS COLUMN0017,
DECIMAL ( ( SUM ( CASE
WHEN ( DAYSWRK BETWEEN 0 AND 20 ) THEN ( FORMCOUNT )
ELSE ( 0 )
END ) ) ) / DECIMAL ( SUM ( FORMCOUNT ) ) AS COLUMN0033,
DECIMAL ( ( SUM ( CASE
WHEN ( DAYSWRK BETWEEN 0 AND 21 ) THEN ( FORMCOUNT )
ELSE ( 0 )
END ) ) ) / DECIMAL ( SUM ( FORMCOUNT ) ) AS "% 11 to 15 Days",


Thanks,


 
Could this be a crosstab report instead? Based on a single calculation that returns the # of Days category?

I am what I am based on the decisions I have made.

DoubleD [bigcheeks]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top