mvchaudhari
MIS
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,
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,