COUNT function in SQL Server with WHERE clause -


i want know count function in sql server where clause

something like...

select      sum(sales) <-- sales     , count(ranking) <-- under 100 ranking     a_chart 

so think...

select     sum(sales)     , count(select * a_chart ranking <= 100)     a_chart. 

a_chart data example

ranking sales 1       100 2       50 3       30 4       5 

then, want know sales sum, ranking under 2.

so, right?

select      sum(all sales), count(ranking < 2)  a_chart. 

please teach me. thanks.

this looking for

select   sum(sales) <-- sales ,count(case when ranking < 100 1 end) <-- under 100 ranking a_chart 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -