Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT u.Username, g.Name AS [Game], COUNT(i.Id) AS [Items COUNT], SUM(i.Price) AS [Items Price]
- FROM Games AS g
- JOIN UserGameItems AS ugi
- ON ugi.UserGameId = g.Id
- JOIN Items AS i
- ON i.Id = ugi.ItemId
- JOIN UsersGames AS ug
- ON ug.GameId = ugi.UserGameId
- JOIN Users AS u
- ON u.Id = ug.UserId
- GROUP BY u.Username, g.Name
- HAVING COUNT(i.Id) >= 10
- ORDER BY [Items COUNT] DESC, [Items Price] DESC, Username
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement