Having a bit of trouble with this sql.
It's bring back too many rows.
The problem is the reference table.
This table has information on each revision, so, it returns all revisions.
SELECT QuoteName, MAX(i.revision) revision,
i.ItemName,
AS 'XrefID',
ref.ID AS 'XrefID' --if this is removed, correct num of rows returned
FROM Items i
LEFT OUTER JOIN PriceQty q ON q.itemid = i.rowID
INNER JOIN PriceRef ref ON ref.PriceQtyID = q.rowid
GROUP BY QuoteName, i.ItemName, ref.ID
ORDER BY QuoteName DESC
I know I'm not seeing something obvious here so an extra set of eyes would be helpful.
Thanks