jim_scott
January 26th, 2006, 06:41 AM
PLEASE HELP.
(select a.partNo as `Part Number`, b.Description as `Part Type`, a.description as `Description`, count(c.itemID) as `Quantity` from partsBoughtIn a, PartType b, itemcost c where a.PartTypeID = b.ID and c.itemType = 'P' and c.itemID = a.id and c.jobmaterialID = 0 group by a.id)
union distinct
(select a.partNo as `Part Number`, b.Description as `Part Type`, a.description as `Description`, 0 as `Quantity` from partsBoughtIn a, PartType b where a.PartTypeID = b.Id) order by `Part Number`
thats a union i use however the first part brings back a count of all those part numbers that have entries in the itemcost table
however the second part i want to bring back those that dont have an entry and make quantity = 0
this query brings back the first part fine, but as expected the second part brings back all the part numbers even those that have entries in item cost.
any ideas how i can get a union to select only distinct part numbers and not distinct whole records.
thanks
frank
(select a.partNo as `Part Number`, b.Description as `Part Type`, a.description as `Description`, count(c.itemID) as `Quantity` from partsBoughtIn a, PartType b, itemcost c where a.PartTypeID = b.ID and c.itemType = 'P' and c.itemID = a.id and c.jobmaterialID = 0 group by a.id)
union distinct
(select a.partNo as `Part Number`, b.Description as `Part Type`, a.description as `Description`, 0 as `Quantity` from partsBoughtIn a, PartType b where a.PartTypeID = b.Id) order by `Part Number`
thats a union i use however the first part brings back a count of all those part numbers that have entries in the itemcost table
however the second part i want to bring back those that dont have an entry and make quantity = 0
this query brings back the first part fine, but as expected the second part brings back all the part numbers even those that have entries in item cost.
any ideas how i can get a union to select only distinct part numbers and not distinct whole records.
thanks
frank