ソースコード
with tmp as(
select
    sa.item_code as CODE
    ,it.item_name as NAME
    ,sum(sa.unitprice * sa.SALES_QTY) as SAL_AMT
from sales_dtl as sa
inner join sales as sal
on sa.sales_no = sal.sales_no
inner join item as it
on sa.item_code = it.item_code
    
where
    sal.sales_date between date('2023-06-01') and date('2023-06-30')

group by
    CODE,NAME


)

select
    CODE
    ,NAME
    ,SAL_AMT
    ,sum(SAL_AMT) over (order by SAL_AMT desc) AS CML_AMT
    ,round(cast(SAL_AMT as double) / (select sum(sal_amt) from tmp) *100,1) || '%' as SAL_COMP
    ,round(cast(sum(SAL_AMT) over (order by SAL_AMT desc) as REAL) / (select sum(sal_amt) from tmp) *100,1) || '%' as TTL_COMP
from tmp
order by 
    SAL_AMT desc
    ,CODE desc
提出情報
提出日時2023/08/02 16:59:45
コンテスト第7回 SQLコンテスト
問題ABC分析
受験者mywk
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
85 MB
データパターン2
WA
77 MB
データパターン3
WA
87 MB