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