Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. ```
  2. WITH RECURSIVE records AS (
  3. SELECT shipping_line_id, MIN(total_price) min_price
  4. FROM rate_detailed_fcl_freight_charges
  5. where origin_port_id='58eb6135c0a35f29ced559c0' and destination_port_id='58ef81f3c0a35f0983b17969' and container_type='standard' and container_size='20' and commodity='general'
  6. GROUP BY shipping_line_id
  7. )
  8. SELECT
  9. r.shipping_line_id,
  10. r.min_price,
  11. frt.freight_forwarder_id,
  12. MAX(frt.date) DATE
  13. FROM rate_detailed_fcl_freight_charges frt JOIN records r ON
  14. frt.shipping_line_id = r.shipping_line_id
  15. AND frt.total_price = r.min_price
  16. GROUP BY r.shipping_line_id, r.min_price, frt.freight_forwarder_id
  17. LIMIT 50;
  18. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement