I'm having issues with my SQL Server code. I am trying to get results to list by the first 4 columns of the select statement. I keep getting syntax errors and am unsure as to why.
What I want it to do is pull by the entityid, acctnum, period that I define but, I don't want to see the period in the results as I want them to be summed together. IE I want see the total activity for the activity column instead of rows for each period.
SELECT
ENTITYID, ACCTNUM, ACCTNAME, ACTIVITY
FROM
(SELECT
g.ENTITYID AS 'ENTITYID'
g.ACCTNUM AS 'ACCTNUM'
SUM(g.ACTIVITY) AS 'ACTIVITY'
h.ACCTNAME AS 'ACCTNAME'
FROM
SQLDATA.DBO.GLSUM g
INNER JOIN
SQLDATA.DBO.GACC h ON g.ACCTNUM = h.ACCTNUM
WHERE
g.ENTITYID = '85000'
g.PERIOD < '201703'
g.ACCTNUM = '569300000')