customer_review/sql/excel_query.sql

23 lines
749 B
MySQL
Raw Permalink Normal View History

2023-12-04 12:09:51 -05:00
SELECT
sw.bill_dba "Bill-To"
,sw.ship_dba "Ship-To"
,sw.dsm "DSM"
,sw.budget_2024 "2024 Budget"
,sw.shipments_2023 "2023 Shipments"
,sw.shipments_2024 "2024 Shipments"
,sw.open_orders_2024 "2024 Open Orders"
--sw.quotes "Quotes",
,(shipments_2024 + open_orders_2024) - budget_2024 "Budget Delta"
,(shipments_2024 + open_orders_2024) - shipments_2023 "YoY Delta"
,CASE sw.newuom WHEN 'Dollars' THEN sw.newords ELSE 0 END "Expected Dollars"
,CASE sw.newuom WHEN 'Pallets' THEN sw.newords ELSE 0 END "Expected Pallets"
,CASE sw.newuom WHEN 'Units' THEN sw.newords ELSE 0 END "Expected Units"
FROM
rlarp.cust_review sw
WHERE
TRUE
--(sw.dsm = ?)
ORDER BY
sw.shipments_2023 desc,
shipments_2024 + open_orders_2024 desc