Hello everyone. As the errormessage (Cannot perform an aggregate function on an expression containing an aggregate or a subquery.) tought me, I can not use subqueries in aggregates. But I just can't figure out how to rewrite the following query so I have no longer a query in the main SELECT statement.SELECT CAST(Row_Number() OVER (ORDER BY SUM(COALESCE (Points, 0)) DESC) AS INT) Ranking, SUM(COALESCE (Points * (SELECT PointMultiplicator FROM [StatusType] s WHERE i.CurrentStatusID = s.StatusTypID), 0)) Cnt, u.UserID, Firstname, Lastname, FreezeIDFROM [User] u LEFT JOIN Idea i ON u.UserID = i.UserID LEFT JOIN Rating r ON r.IdeaID = i.IdeaIDGROUP BY u.UserID, Firstname, Lastname, FreezeID
I hope that someone is able to help me. My SQL skills aren't that good and I'm really stuck on this one.If you need more information, please tell me so.Sincerely, Yukite