コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with table1 as (
select
case strftime("%w", sales_date)
WHEN '0' THEN '日'
WHEN '1' THEN '月'
WHEN '2' THEN '火'
WHEN '3' THEN '水'
WHEN '4' THEN '木'
WHEN '5' THEN '金'
WHEN '6' THEN '土'
end as WEEK,
strftime("%w", sales_date) as week_number,
count(*) as counts,
sum(sales_amt) as sums
from
SALES
where
SALES_TYPE <> 2
and UPDATED_NO is null
and sales_date between "2024-03-01" and "2024-03-28"
group by
WEEK
)
select
WEEK,
round(sum(AVG_CNT)/4.0, 0) as AVG_CNT,
printf("%,d", round(sum(AVG_AMT)/4.0, 0))||"円" as AVG_AMT
from (
select
WEEK,
counts as AVG_CNT,
sums as AVG_AMT,
week_number
from
table1
)
union select "日" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "0" as week_number
union select "月" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "1" as week_number
union select "火" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "2" as week_number
union select "水" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "3" as week_number
union select "木" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "4" as week_number
union select "金" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "5" as week_number
union select "土" as WEEK, 0 as AVG_CNT, 0 as AVG_AMT, "6" as week_number
group by
week_number
order by
week_number
提出情報
提出日時 | 2024/04/21 12:42:56 |
コンテスト | 第12回 SQLコンテスト |
問題 | 曜日別売上分析 |
受験者 | yrarchi |
状態 (詳細) | RE (Runtime Error: 実行時エラー) |
メモリ使用量 | 83 MB |
メッセージ
SQLITE_ERROR: SELECTs to the left and right of UNION do not have the same number of result columns
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
83 MB
データパターン2
RE
83 MB