03-04-2024 10:38 AM - edited 03-04-2024 10:39 AM
Hi There!
I wrote the below case statement. But it is not giving the required results. I WANT 93,855 BUT I'M GETTING 938.5566666666666666666 like this.
(SELECT CASE (MAIN.RECEIPT+MAIN.ISSUE) WHEN 0 THEN 0.0 ELSE MAIN.AMOUNT/(MAIN.RECEIPT+MAIN.ISSUE) END) AS UNITP
So I tried writing the nested case statement for the above line and it worked but in the output, I'm getting so many numbers after decimal. I want the number to round off and I have tried ROUND( ) as well it is throwing an error maybe I misplaced the function. Can anyone let me know how to use ROUND( ) in nested case statements? Thanks
CASE
WHEN
case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end
+
case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end = 0
THEN 0.00
ELSE
CASE
WHEN
CASE WHEN MSEG.DMBTR = 0 THEN 0 ELSE 0.00 END = 0
AND
CASE WHEN MSEG.MENGE = 0 THEN 0 ELSE 0.00 END = 0
AND
case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end = 0
AND
case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end = 0
THEN 0
ELSE
MSEG.DMBTR/
(case MSEG.SHKZG when 'S' then MSEG.MENGE else 0.0 end
+
case MSEG.SHKZG when 'H' then MSEG.MENGE else 0.0 end)
END
END
AS UNITP,
User | Count |
---|---|
75 | |
10 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.