forecast_api/over_under_ship.sql

16 lines
343 B
MySQL
Raw Normal View History

2021-04-13 16:01:00 -04:00
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;