Advertisement
social1986

Untitled

Jun 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.76 KB | None | 0 0
  1. SELECT TOP(5) CountryName,
  2.               HighestPeakElevation,
  3.               LongestRiverLength
  4. FROM   (SELECT c.CountryName    AS [CountryName],
  5.                Max(p.Elevation) AS [HighestPeakElevation],
  6.                Max(r.Length)    AS [LongestRiverLength]
  7.         FROM   countries AS c
  8.                LEFT JOIN mountainscountries AS mc
  9.                       ON mc.countrycode = c.countrycode
  10.                LEFT JOIN peaks AS p
  11.                       ON p.mountainid = mc.mountainid
  12.                LEFT JOIN countriesrivers AS cr
  13.                       ON cr.countrycode = c.countrycode
  14.                LEFT JOIN rivers AS r
  15.                       ON r.id = cr.riverid
  16.         GROUP  BY c.CountryName) AS cc
  17. ORDER  BY HighestPeakElevation DESC,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement