hearmeroar
hearmeroar

Reputation: 307

Get to 2 decimal places

I have this line of query here

if (type = 1,

(IF(ISNULL(users), 
'', 
((SUM(actual) / 1) * 0.04/12) * if(users = "user", booked/(36/12),'')
))

,
'false')

the example output is 123.3333333

I want it to output just 2 decimals so it'll be like 123.33 where should I place the Truncate or Round command?

Thank You!

Upvotes: 0

Views: 137

Answers (2)

Franzl
Franzl

Reputation: 719

How about:

if (type = 1,
(IF(ISNULL(users), '', ROUND(((SUM(actual) / 1) * 0.04/12) * if(users_0.user_name = "user", booked/(36/12),''),2)))
, 'false')

Upvotes: 2

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44874

You can use truncate()

TRUNCATE(123.3333333, 2) = 123.33


if (type = 1,
(
  IF(ISNULL(users), '', 
  TRUNCATE(
  (
    (SUM(actual) / 1) * 0.04/12) * if(users_0.user_name = "user", booked/(36/12),'')
  ),2)

)

,
'false')

Upvotes: 1

Related Questions