Skip to content
Advertisement

Tag: inventory-management

How can I write a Postgres (SQL) query for FIFO ‘closing stock’ inventory valuation?

Background I need to implement inventory valuation / costing using the FIFO (first-in, first-out) method. I’m running Postgres 11 running on CentOS 7. I’ve looked at, and tried, a fair number of hypotheses from SO and the wider internet (as well as searching my own print library which includes SQL Queries for Mere Mortals, PostgreSQL Up & Running, The SQL

Check If Date Falls In Period With Year Unspecified

I’ve got a table that defines several non-overlapping date periods using only month and day. It’s basically a “stocking” table for inventory items that allows you to stock different amounts across the year for seasonal businesses. Here’s an example of how a single item’s stocking table might look. Note that I have an Items table that I’m not showing here.

Advertisement