Tuesday, October 23, 2018

Sample SQL Query to Identify which Items not Purchased within a Date Range


Sample SQL query to identify which Inventory Items not purchased within a specified date range:

SELECT item_id
FROM items table
WHERE type_name is 'Inventory Item' --> Item type
AND Item_id not including
     (SELECT DISTINCT item_id
     FROM Transaction_lines table
     WHERE date_closed
          BETWEEN <start_date> and <end_date>) --> Date range

No comments:

Post a Comment