ソースコード
with total_value_ord as (
select
TOTAL_VALUE
,ROW_NUMBER() OVER (ORDER BY TOTAL_VALUE DESC) as row_num
from convenience
where SURVEY_YEAR=2019
AND KIND_CODE=100
), get_row_num as (
select 
max(row_num)/2 as medium_row
,max(row_num)%2 as rest
from total_value_ord
)
select
CAST(ROUND(sum(cast(total_value as FLOAT))/count(0)) as INTEGER) as SA_MEDIAN
from total_value_ord
where row_num >= (select medium_row + rest from get_row_num)
and row_num <= (select case when rest=0 then medium_row+1 else medium_row + rest end from get_row_num)
提出情報
提出日時2022/12/12 10:26:46
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者crazyteabag
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
96 MB
データパターン3
AC
82 MB