1

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

  • The solution is : SELECT name, ROUND((COUNT(*) filter (where religion = 'Orthodox Christian')) 100/ (COUNT() ),2) as orth_chri FROM dataset_1 GROUP BY name – Pablo Gallego Cadabón Nov 28 '16 at 15:53
1

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, privacy policy and cookie policy

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