no message

This commit is contained in:
AzureAD\SylvainDUVERNAY
2026-02-02 15:52:52 +01:00
parent 7f99b78c8a
commit 0fa522ece6
6 changed files with 134 additions and 5 deletions

38
vw_bi_fct_trade_line.sql Normal file
View File

@@ -0,0 +1,38 @@
-- Fact Trade Line View
-- This view consolidates trade line data from both purchase and sale physical contracts and derivatives
CREATE OR REPLACE VIEW vw_bi_fct_trade_line AS
SELECT
pc."intPurchaseLineId" AS "intTradeId",
'Physical' AS "Trade Category",
'Purchase' AS "Trade Type",
pc."dtmEstimatedBLDate" AS "Delivery Date",
pc."dblTheoriticalQuantity" AS "Contracted Quantity",
pc."dblQuantity" AS "Quantity",
pc."dblPrice" AS "Price",
pc."dblUnitPrice" AS "Unit Price",
'USD' AS "Price Currency",
pc."dblLineAmount" AS "Line Amount"
FROM vw_utility_purchase_physical_contract pc
UNION ALL
SELECT
pc."intSaleLineId" AS "intTradeId",
'Physical' AS "Trade Category",
'Sale' AS "Trade Type",
pc."dtmEstimatedBLDate" AS "Delivery Date",
pc."dblTheoreticalQuantity" AS "Contracted Quantity",
pc."dblQuantity" AS "Quantity",
pc."dblPrice" AS "Price",
pc."dblUnitPrice" AS "Unit Price",
'USD' AS "Price Currency",
pc."dblLineAmount" AS "Line Amount"
FROM vw_utility_sale_physical_contract pc;
-- UNION ALL
-- Derivative contracts can be added here in the future
ALTER TABLE public.vw_bi_fct_trade_line
OWNER TO postgres;