Monday, April 11, 2016

SQL Performance enhancement for count function

SQL count aggregate function with case is helpful to reduce time to process sql db.
If you want count for any column bases on the value we can use the count function with case to reduce the processing time.

e..g. select count(case column1 when 'value1' then 1 else null end) as count1, count(case column1 when 'value2' then 1 else null end) as count2 from table1

No comments:

Post a Comment