I would like to get the sum of a column, but am having trouble with a condition
| Target | MultiOnQry |
---------------------------
| 50393 | 1 |
| 49 | 1 |
| 303 | 0 |
| 1934 | 1 |
| 45 | 0 |
---------------------------
I want to sum the truncated values from the target column, but want to multiply by X if MultiOnQry = 1. This is being called from vba, so I will substitute X for the scalar.
SELECT SUM(CAST(Target*X AS Integer)) AS TargetSum FROM table WHERE ID = 1078
Aucun commentaire:
Enregistrer un commentaire