I want to make INT be the data type for this column I'm creating. How do I do that? I tried adding AS INT to the end of END AS "salary_deviation" but that does not work. I tried wrapping END AS in CAST() but that didnt work either.
CASE
WHEN c.salary = pair.salary THEN '6'
WHEN c.salary-pair.salary <= 25000 THEN '5'
WHEN c.salary-pair.salary <= 50000 THEN '4'
WHEN c.salary-pair.salary <= 75000 THEN '3'
WHEN c.salary-pair.salary <= 100000 THEN '2'
ELSE
'1'
END AS "salary_deviation"
Any ideas on the syntax to do this?
CodePudding user response:
CASE
WHEN c.salary = pair.salary THEN 6 :: integer
WHEN c.salary-pair.salary <= 25000 THEN 5
WHEN c.salary-pair.salary <= 50000 THEN 4
WHEN c.salary-pair.salary <= 75000 THEN 3
WHEN c.salary-pair.salary <= 100000 THEN 2
ELSE 1
END AS "salary_deviation"