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