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;