distinct
SELECT distinct
ol.stock_code,
ol.qty_ordered AS stock_ordered,
l.date_expected
FROM dbo.tbl_purchase_order_lines as ol
INNER JOIN dbo.tbl_purchase_orders as l
ON ol.purchase_order_id = l.id
WHERE
(l.delivery_complete = 0) AND
(l.date_expected > GETDATE() - 1)
ORDER BY stock_code, date_expected
ie just add the distinct, the top 100 percent looks effectively redundant anyway, also corelation names (table aliases) make it easier to read and less typing
Mike John
|