79337545

Date: 2025-01-07 22:52:37
Score: 1.5
Natty:
Report link

I have found that casting to numeric with scale 2 then casting back to float works best.

`SELECT

j.job_title,

AVG(j.salary)::NUMERIC(10,2)::FLOAT as average_salary,

COUNT(p.id) as total_people,

SUM(j.salary)::NUMERIC(10,2)::FLOAT as total_salary

FROM people p

JOIN job j

ON p.id = j.people_id

GROUP BY j.job_title;`

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Toluse Alemika