February 18, 2011 at 3:22 am
Hello, I hope someone can help me out. I am trying to select the maximum log size in a table column, and then add up the result to get a total. So far I have...
select sum(LogsizeInMB) as TotalMB
from
(
select databasename, max(logsize) as LogsizeInMB
from dbo.logSpaceStats
)
group by databasename
Result:Msg 156, Level 15, State 1, Line 7
Incorrect syntax near the keyword 'group'.
I feel as though I am almost there, but obviously missing something.
Thank you,
P
February 18, 2011 at 3:31 am
Maybe this is what you need:-
select sum(LogsizeInMB) as TotalMB
from
(
select databasename, max(logsize) as LogsizeInMB
from dbo.logSpaceStats
group by databasename
) as logsize
February 18, 2011 at 3:38 am
That did the trick, thank you. This is what I ended up with before your help, I can see where I was getting it wrong and will help in future.
select databasename, sum(logSize)as TotalMB
(
select databasename, max(logsize)as LogsizeInMB
from dbo.logSpaceStats
)
order by databasename
Thanks again,
P
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply