ソースコード

select
a1.item_code as CODE
,a1.item_name as NAME
,t1.total_amt as SAL_AMT
,t1.cml as CML_AMT
,round(100.0*t1.total_amt/(max(cml) over()),1)||'%' as SAL_COMP
,round(100.0*t1.cml/(max(cml) over()),1)||'%' as TTL_COMP
,case
    when round(100.0*t1.cml/(max(cml) over()),1) <= 40 then 'A'
    when round(100.0*t1.cml/(max(cml) over()),1) >= 40 and round(100.0*t1.cml/(max(cml) over()),1) <= 80 then 'B'
    else 'C'
end as RANK
from item as a1
inner join(
    select
    a.item_code as item
    ,t.total_amt
    ,sum(total_amt) over (order by total_amt desc) as cml
    from item as a
    inner join (
        select
        sd.item_code as item
        ,sum(unitprice*delivered_qty) as total_amt
        from sales as s
        inner join sales_dtl as sd
        on s.sales_no=sd.sales_no
        where sales_date between '2023-06-01' and '2023-06-30'
        group by sd.item_code
        order by total_amt desc,sd.item_code desc
    ) as t
    on t.item=a.item_code
    order by total_amt desc
) as t1
on t1.item=a1.item_code
order by total_amt desc
提出情報
提出日時2024/05/30 11:31:24
コンテスト第7回 SQLコンテスト
問題ABC分析
受験者HamamatsuUnagi
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
1/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
WA
84 MB
データパターン3
WA
86 MB