September 22, 2008 at 12:03 am
I have the following piece of SQL code which runs without any problems:
SELECT year, Q1Amt + Q2Amt + Q3Amt + Q4Amt AS Actual
FROM Table1
WHERE (buildingID = @buildingID)
ORDER BY year
I get around 400 records in my result set.
What I now need to do is group by Year & Actual, so I only end up with one figure for each year.
As soon as I add something like the following, everything comes unstuck.
GROUP BY finyear, SUM(Q1Amt + Q2Amt + Q3Amt + Q4Amt)
September 22, 2008 at 12:13 am
Kerrie Jones (9/22/2008)
I have the following piece of SQL code which runs without any problems:SELECT year, Q1Amt + Q2Amt + Q3Amt + Q4Amt AS Actual
FROM Table1
WHERE (buildingID = @buildingID)
ORDER BY year
I get around 400 records in my result set.
What I now need to do is group by Year & Actual, so I only end up with one figure for each year.
As soon as I add something like the following, everything comes unstuck.
GROUP BY finyear, SUM(Q1Amt + Q2Amt + Q3Amt + Q4Amt)
See if this is what you wanted
SELECT year, SUM(Q1Amt + Q2Amt + Q3Amt + Q4Amt) AS Actual
FROM Table1
WHERE (buildingID = @buildingID)
GROUP BY year
ORDER BY year
or post some sample data with expected result
Failing to plan is Planning to fail
September 22, 2008 at 12:18 am
That works like a bought one. Thankyou for the quick response.:D
September 22, 2008 at 12:59 am
Kerrie Jones (9/22/2008)
That works like a bought one. Thankyou for the quick response.:D
You are welcome 🙂
Failing to plan is Planning to fail
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply