ソースコード
SELECT 
WEEK
, round(count(WEEK)) AS AVG_CNT
, case
  when  length(round(avg(AVG_AMT)) ) > 6
     then substr(round(avg(AVG_AMT)) ,1,length(round(avg(AVG_AMT)) )-6) || ',' || substr(round(avg(AVG_AMT)) ,length(round(avg(AVG_AMT)) )-5,3) || ',' || substr(round(avg(AVG_AMT)) ,length(round(avg(AVG_AMT)) )-2,3)
  when  length(round(avg(AVG_AMT)) ) > 3
     then substr(round(avg(AVG_AMT)) ,1,length(round(avg(AVG_AMT)) )-3) || ',' || substr(round(avg(AVG_AMT)) ,length(round(avg(AVG_AMT)) )-2,3)
  else  round(avg(AVG_AMT)) 
 end As AVG_AMT
from 
(select SALES_DATE
,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 '土'
        else 'undefined'
end as WEEK
, SUM(SALES_AMT) as AVG_AMT
FROM SALES
where SALES_TYPE <> 2 AND UPDATED_NO IS NULL
gRoup by SALES_DATE
having SUM(SALES_AMT) >= 0
) AS A
gRoup by WEEK
-- --having COUNT(*) = 0
 ORDER BY CASE 
           WHEN WEEK = '日' THEN 1 
           WHEN WEEK = '月' THEN 2 
           WHEN WEEK = '火' THEN 3 
           WHEN WEEK = '水' THEN 4 
           WHEN WEEK = '木' THEN 5 
           WHEN WEEK = '金' THEN 6 
           ELSE 7
       END
提出情報
提出日時2024/04/22 13:04:29
コンテスト第12回 SQLコンテスト
問題曜日別売上分析
受験者nmanh
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
85 MB