list all quotes
This commit is contained in:
parent
618a744e05
commit
6d987ee0aa
69
sql/live_quote_nohist.pg.sql
Normal file
69
sql/live_quote_nohist.pg.sql
Normal file
@ -0,0 +1,69 @@
|
||||
DROP TABLE IF EXISTS rlarp.live_quotes_nohist;
|
||||
|
||||
CREATE TABLE rlarp.live_quotes_nohist AS
|
||||
WITH
|
||||
lq AS MATERIALIZED (
|
||||
SELECT
|
||||
lq.*
|
||||
,substring(lq.part,1,8) mold
|
||||
FROM
|
||||
pricequote.live_quotes lq
|
||||
)
|
||||
,lqg AS (
|
||||
SELECT
|
||||
lq.*
|
||||
,pricing->'product'->>'mold' part_group
|
||||
,substring(pricing->'customer'->>'chan',1,1) qchan
|
||||
,pricing->'customer'->>'cust' qcust
|
||||
,pricing->'product'->>'itemrel' item_fit
|
||||
,(pricing->'product'->>'pltq')::numeric pltq
|
||||
,(pricing->'guidance'->'finalPrice'->>'Price')::numeric guidance
|
||||
,pricing->'guidance'->'finalPrice'->>'Reason' reason
|
||||
,(pricing->'product'->>'fstd_usd_ina')::numeric fstd_usd
|
||||
,(pricing->'guidance'->>'ltp')::numeric ltp
|
||||
,(pricing->'guidance'->>'optimization')::numeric optimization
|
||||
,(pricing->'guidance'->>'inflationFactor')::numeric inflation
|
||||
,jsonb_pretty(pricing) pricing
|
||||
FROM
|
||||
lq
|
||||
LEFT JOIN LATERAL rlarp.guidance_r1(
|
||||
rlarp.get_guidance_dseg(lq.billto,lq.shipto,substring(lq.part,1,8),lq.v1ds,lq.units_each,2024)
|
||||
) pricing ON TRUE
|
||||
WHERE
|
||||
TRUE
|
||||
--lq.qstat ~ 'Submitted'
|
||||
)
|
||||
--,hist AS (
|
||||
-- SELECT
|
||||
-- g.*
|
||||
-- ,gset.chan
|
||||
-- --,gset.mold moldh
|
||||
-- ,gset.v1ds v1dsh
|
||||
-- ,gset.cust
|
||||
-- ,gset.vers
|
||||
-- ,je.k
|
||||
-- ,seas.*
|
||||
-- FROM
|
||||
-- lqg g
|
||||
-- LEFT OUTER JOIN rlarp.price_pool_dev p ON
|
||||
-- p.gset @> jsonb_build_object('mold',g.part_group)
|
||||
-- AND p.gset ? 'cust'
|
||||
-- AND p.gset ? 'v1ds'
|
||||
-- LEFT JOIN LATERAL jsonb_to_record(p.gset) AS gset(
|
||||
-- chan text
|
||||
-- ,mold text
|
||||
-- ,v1ds text
|
||||
-- ,v0ds text
|
||||
-- ,cust text
|
||||
-- ,vers text
|
||||
-- --,nurs text
|
||||
-- --,ghse text
|
||||
-- ) ON TRUE
|
||||
-- LEFT JOIN LATERAL jsonb_each(p.season) je(k,v) on true
|
||||
-- LEFT JOIN Lateral jsonb_to_record(je.v) as seas(
|
||||
-- units numeric
|
||||
-- ,sales_usd numeric
|
||||
-- ,price_usd numeric
|
||||
-- ) ON TRUE
|
||||
--)
|
||||
SELECT * FROM lqg;
|
@ -1,3 +1,5 @@
|
||||
set work_mem TO '4GB';
|
||||
|
||||
DROP VIEW rlarp.live_quotes_review;
|
||||
CREATE OR REPLACE VIEW rlarp.live_quotes_review AS
|
||||
WITH
|
||||
|
Loading…
Reference in New Issue
Block a user