jon/py/jon/db/get_inventory_overview.sql
2023-05-17 12:43:43 +02:00

21 lines
613 B
SQL

SELECT
inventory_items.item_id,
inventory_items.item_barcode,
inventory_items.name,
inventory_items.unit_price,
inventory_items.bought,
inventory_item_overview.group_name,
inventory_item_overview.units_left,
inventory_item_overview.correction_delta,
inventory_item_overview.sales_units,
inventory_item_overview.active_mappings,
inventory_item_overview.location_name
FROM garfield.inventory_item_overview
LEFT JOIN garfield.inventory_items USING (item_id)
WHERE
(%(location_id)s IS NULL OR inventory_items.location = %(location_id)s)
ORDER BY
name ASC,
item_barcode DESC,
bought DESC