2

I am try to round the expression below on carto but it still returns no decimal places. The columns are 'number' type. I have also tried SELECT round( CAST(column as numeric), 2 ) suggested here but no decimals either.

SELECT name,

ROUND((COUNT(*) filter (where religion = 'Orthodox Christian')) *100/ (COUNT(*) ),2) as orth_chri

FROM dataset_1
GROUP BY name
1
  • The solution is : SELECT name, ROUND((COUNT(*) filter (where religion = 'Orthodox Christian')) 100/ (COUNT() ),2) as orth_chri FROM dataset_1 GROUP BY name Commented Nov 28, 2016 at 15:53

1 Answer 1

3

The solution is to put ::numeric to change the data type

SELECT name, ROUND((COUNT() filter (where religion = 'Orthodox Christian')) 100/ (COUNT() ) ::numeric,1) as orth_chri

FROM dataset_1 GROUP BY name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.