commit: 2025-04-05 22:46:04
This commit is contained in:
parent
fb749ffde5
commit
ce2fe219f4
@ -236,14 +236,28 @@ GROUP BY
|
||||
,r_currency
|
||||
,order_date
|
||||
,ship_date
|
||||
,round(pounds_net / sum(pounds_net) OVER (),5) fc_mix
|
||||
,round(pounds_baseline / sum(pounds_baseline) OVER (),5) baseline_mix
|
||||
,CASE WHEN sum(pounds_net) OVER () = 0 THEN 0 ELSE round(pounds_net / sum(pounds_net) OVER (),5) END fc_mix
|
||||
,CASE WHEN sum(pounds_baseline) OVER () = 0 THEN 0 ELSE round(pounds_baseline / sum(pounds_baseline) OVER (),5) END baseline_mix
|
||||
FROM
|
||||
alldates
|
||||
ORDER BY
|
||||
order_date ASC
|
||||
,ship_date ASC
|
||||
)
|
||||
,part_mix as (
|
||||
SELECT
|
||||
part
|
||||
,sum(units) qty
|
||||
,ROUND(CASE WHEN sum(units) = 0 THEN 0 ELSE sum(value_usd)/sum(units) END,5) price
|
||||
,sum(pounds) pounds
|
||||
FROM
|
||||
rlarp.osm_pool
|
||||
WHERE
|
||||
where_clause
|
||||
AND version = 'b26'
|
||||
GROUP BY
|
||||
part
|
||||
)
|
||||
-- select 'custs', * from custs
|
||||
--
|
||||
SELECT
|
||||
@ -262,4 +276,6 @@ SELECT
|
||||
,(SELECT jsonb_agg(row_to_json(custs)::jsonb) FROM custs)
|
||||
,'date_mix'
|
||||
,(SELECT jsonb_agg(row_to_json(date_mix)::jsonb) FROM date_mix)
|
||||
,'part_mix'
|
||||
,(SELECT jsonb_agg(row_to_json(part_mix)::jsonb) FROM part_mix)
|
||||
) package
|
||||
|
||||
Loading…
Reference in New Issue
Block a user