Last active
August 29, 2015 14:01
-
-
Save niisar/ddfe7acdce7204c92e37 to your computer and use it in GitHub Desktop.
Ch6_1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH WT_M AS | |
(SELECT FIRSTNAME, | |
WEIGHT, | |
ROW_NUMBER() over (order by WEIGHT DESC) AS WT_RANK_MALE | |
FROM CHILDSTAT | |
WHERE GENDER = 'm' | |
), | |
WT_F AS | |
(SELECT FIRSTNAME, | |
WEIGHT, | |
ROW_NUMBER() over (order by WEIGHT DESC) AS WT_RANK_FEMALE | |
FROM CHILDSTAT | |
WHERE GENDER = 'f' | |
) | |
SELECT a.FIRSTNAME AS FIRSTNAME_MALE, | |
a.WEIGHT AS WEIGHT_MALE, | |
B.FIRSTNAME AS FIRSTNAME_FEMALE, | |
B.WEIGHT AS WEIGHT_FEMALE | |
FROM WT_M a | |
INNER JOIN WT_F B | |
ON A.WT_RANK_MALE = B.WT_RANK_FEMALE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment