Creating SumIf function in SQL Server 2012 -


i need building sql server function acts sumif in excel, example

sumif(fees.fee_amount, fees.type ='services' , fees.fee_code = 'b01') 

so item summed if fees.fee_amount , part fees.type ='services' , fees.fee_code = 'b01'

syntax sumif(tablename.columnname, criteria), function return total.

the simplest way sum case clause, so:

sum(case when fees.type ='services' , fees.fee_code = 'b01'          fees.fee_amount     end) columnalias, 

Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -