Advertisement
simonradev

Bullshit

Sep 16th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.44 KB | None | 0 0
  1. SELECT u.Username,
  2.        g.Name,
  3.        COUNT(*) AS [Items Count],
  4.        SUM(i.Price) AS [Items Price]
  5.  FROM Games AS g
  6.  INNER JOIN UsersGames AS ug
  7.  ON g.Id = ug.GameId
  8.  INNER JOIN Users AS u
  9.  ON ug.UserId = u.Id
  10.  INNER JOIN UserGameItems AS ugi
  11.  ON ug.Id = ugi.UserGameId
  12.  INNER JOIN Items AS i
  13.  ON ugi.ItemId = i.Id
  14.  GROUP BY u.Username, g.Name
  15.  HAVING COUNT(*) >= 10
  16.  ORDER BY COUNT(*) DESC,
  17.           SUM(i.Price) DESC,
  18.           u.Username ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement