Skip to content

Instantly share code, notes, and snippets.

@doryokujin
Created April 23, 2015 05:30
Show Gist options
  • Save doryokujin/eb13424bc06fbacd819a to your computer and use it in GitHub Desktop.
Save doryokujin/eb13424bc06fbacd819a to your computer and use it in GitHub Desktop.
SELECT number1, number2, COUNT(1) AS cnt
FROM
(
SELECT n1.symbol,n2.symbol, n1.number AS number1, n2.number AS number2
FROM
(
SELECT number, symbol
FROM trump_part
WHERE symbol!='joker'
) n1
JOIN
(
SELECT number, symbol
FROM trump_part
WHERE symbol!='joker'
) n2
ON n1.symbol = n2.symbol
HAVING n1.number < n2.number
) tmp
GROUP BY number1, number2
ORDER BY cnt DESC, number1, number2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment