Perform arithmetic in SQL -
could please me this? have following query returns country name, number of records each country, , total number of countries . how can return column % of each country respect total number. ideal output like.
usa, 25, 100, 25% ... uk, 28, 100, 28% ... etc...
select country, count(country) number, (select count(country) from[customers]) total [customers] group country order number desc i have tried number/total percent didn't work. doing wrong.
i want able filter countries above percentage 20%.
thanks!
use derived table, subquery alias.
select number/total percent ( query goes here ) derivedtable
Comments
Post a Comment