From 94ae5e192c449e238dfa31f47a5efa4301830f4c Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 13 Apr 2021 16:01:00 -0400 Subject: [PATCH] isolate short an over shipments --- over_under_ship.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 over_under_ship.sql diff --git a/over_under_ship.sql b/over_under_ship.sql new file mode 100644 index 0000000..aec6a87 --- /dev/null +++ b/over_under_ship.sql @@ -0,0 +1,15 @@ +SELECT + calc_status, + flag, + sum(fb_val_loc * r_rate) filter (where fb_qty < 0) overship, + sum(fb_val_loc * r_rate) filter (where fb_qty > 0) undership +FROM + rlarp.osm_dev +WHERE + oseas = 2021 + AND version = 'ACTUALS' + AND calc_status = 'CLOSED' + AND flag = 'REMAINDER' +GROUP BY + calc_status, + flag;