sql - multiply and sum column on condition -


i sum of column, having trouble condition

|  target  |  multionqry  |    --------------------------- |  50393   |       1      | |  49      |       1      | |  303     |       0      | |  1934    |       1      | |  45      |       0      | --------------------------- 

i want sum truncated values target column, want multiply x if multionqry = 1. being called vba, substitute x scalar.

select sum(cast(target*x integer)) targetsum table id = 1078 

 select sum(case when multionqry = 0          cast(target integer)          else cast(target integer)*x end) targetsum  table id = 1078 

try this.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -