Guest User

Untitled

a guest
Nov 12th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. -- This query returns the two most populated cities
  2. -- for each country using the APPLY operator
  3. SELECT C.Name, P.Name, P.Population
  4. FROM Example.Countries C
  5. CROSS APPLY (
  6. SELECT TOP (2) I.Name, I.Population
  7. FROM Example.Cities AS I
  8. WHERE I.CountryID = C.CountryID
  9. ORDER BY I.Population
  10. ) AS P
Add Comment
Please, Sign In to add comment