'SQL SUM with condition / Invalid column name 'SUM'
I'm trying to make a sum of the variable value/valeur with some conditions but I obtain this error: Invalid column name 'SUM'.
SELECT SUM[value/valeur]
FROM [dbo].[tmp_norm_can]
WHERE [state/etat] = '1000'
AND [geo/geo] = '1'
AND [country/pays] != '999'
I attached an image of the database
Thank you very much!
Solution 1:[1]
sum is a function, you need to pass its argument in parentheses:
SELECT SUM([value/valeur])
FROM [dbo].[tmp_norm_can]
WHERE [state/etat] = '1000'
AND [geo/geo] = '1'
AND [country/pays] != '999'
Solution 2:[2]
Try aliasing your column with a name different than "SUM".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | BrutalPeanut |
