Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SUM Function requires 1 argument

$
0
0

using this as a guide, (https://www.w3schools.com/sql/sql_count_avg_sum.asp)

The current code that i am using is below

Text
select sum (mon1emp,mon2emp,mon3emp) from dbo.xyz where zip = '89411' or zip = '89448' or zip = '89449' and year = '2016' or year = '2017' or year '2018' 

The data is establishment level and the client wants to have the establishments summed up by zipcode and by year. This is quarterly data hence why the mon1emp, mon2emp, mon3emp. This seems rudimentary but what I try online involves aliases and that seems unnecessary. Any other ideas?

The data looks sort of like this

state year qtr name zip emp mon1empmon2empmon3emp

32 2016 1 john 89449 120 100 140 120

32 2016 2 jane 89448 7 10 2 9

32 2016 2 juan 89449 16 10 14 24

desired result

year ...


Viewing all articles
Browse latest Browse all 4871

Trending Articles