I have the following query and it gives me an error :"Incorrect syntax near the keyword 'GROUP'." <-shows me the second GROUP BY statement...Can you tell me why?
SELECTventId
,TargetUser
,TargetDomain
,String05
,Amount
,max(Amount) maximum
FROM
(SELECT EventId
, TargetUser
, TargetDomain
, String05
FROM AdtServer.dvAll
GROUP BY EventId, TargetUser, TargetDomain, String05)
GROUP BY EventId,TargetUser,TargetDomain,String05,Amount //ERROR SHOWS HERE
ORDER BY maximum,TargetUser
If I create view for inner query it works fine(But I don't want to create a view because if my query is long-running query it gives me time-out).