sql - MSsql select count case only if > 0 -


i have query select , display values matching criteria

with cte (      select row_number() over(order cars.make asc,cars.model asc) rn, cars.id, cars.make          cars          left join transport on cars.transportfrom=transport.id          make in ('daihatsu','dodge','jeep','kia','lancia') )  select make, count(case when rn between 51 , 100 1 end) countinresponse, count(1) total      cte      group make 

i got result

make        |   countinresponse |   total daihatsu    |   0               |   5 dodge       |   0               |   2 jeep        |   0               |   14 kia         |   10              |   39 lancia      |   17              |   17 

but how result > 0?

make        |   countinresponse |   total kia         |   10              |   39 lancia      |   17              |   17 

with cte (  select row_number() over(order cars.make asc,cars.model asc) rn, cars.id, cars.make      cars      left join transport on cars.transportfrom=transport.id      make in ('daihatsu','dodge','jeep','kia','lancia') )   select make, count(case when rn between 51 , 100 1 end)      countinresponse, count(1) total   cte   group make  having count(case when rn between 51 , 100 1 end) > 0 

you should add having clause @ end.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -