I have one table having two columns named OrderId and OrderType
OrderId OrderType
------- ---------
1 Drawer
2 Pickup
3 Delivery
4 Delivery
5 Drawer
In my stored procedure I want to pass the argument of OrderType which would return a result only on matching OrderType Column data to the argument i.e. if I pass the argument 'Drawer' then it should return count of OrderType column where OrderType column data is 'Drawer' and so on.
How can i do that using Count?
Currently I am doing:
select @tempvar1=case @tempvar
when 'Drawer'
Then Count(CASE_TABLE.OrderType) --What Should i put here to get desired result?
end
select @tempvar1
Instead of counting the whole column I want only the count matching OrderType.
WHEREclause to get your specific data? If so use aWHEREclause after your second select like you would in a normal query.Count()