Created
September 20, 2015 08:27
-
-
Save yuki-takeichi/ec832269ee1b8165b3c0 to your computer and use it in GitHub Desktop.
AtCoderをSQLで解く遊び(abc028_c)
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
-- 多分Postgresでしか動かない | |
with nums as ( | |
select column1 as n | |
from ( | |
values(1),(2),(3),(4),(5) | |
) t | |
) | |
, sums as ( | |
select n1.n + n2.n + n3.n as n | |
from nums n1 | |
, nums n2 | |
, nums n3 | |
where n1.n <> n2.n | |
and n2.n <> n3.n | |
and n3.n <> n1.n | |
order by n1.n desc | |
, n2.n desc | |
, n3.n desc | |
) | |
select distinct sums.n | |
from sums | |
order by sums.n desc | |
limit 1 offset 2 | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment