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
Post a Comment