Advertisement
livingdub

Untitled

Aug 23rd, 2019
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.52 KB | None | 0 0
  1. SELECT T2.Beername, T2.Brewername, T2.Beerprice
  2. FROM (
  3.      SELECT Brewers.Name AS BrewerName, MAX(Price) AS MaxPrice
  4.     FROM Beers INNER JOIN Brewers ON Beers.BrewerId = Brewers.Id
  5.     GROUP BY Brewers.Id
  6.     ) AS T1
  7.     INNER JOIN (
  8.         SELECT Brewers.Name AS BrewerName, Beers.Name AS Beername, Beers.Price AS BeerPrice
  9.         FROM Brewers INNER JOIN Beers ON Brewers.Id = Beers.BrewerId
  10.          ) AS T2
  11.         ON T1.MaxPrice = T2.BeerPrice AND T1.BrewerName = T2.BrewerName
  12. ORDER BY T2.BrewerName, T2.Beername;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement