I have two tables that I would like to pull information from. TableA has my part information, and TableB has the vendor specific information about that part. A partID can exist only once in the TableA, but partID can exist many times in TableB (once per vendor). In the live data, a particular partID will most often be purchased from only one vendor, but some partID’s may be purchased from 2 or 3 different vendors. I am attempting to list out this information in a query, showing a single row for each TableA.partID:
TableA.partID, TableA.desc, TableA.uom, TableB.vendorID, TableB.quote, TableB.vendorID as vendorID2, TableB.quote as quote2, TableB.vendorID as vendorID3, TableB.quote as quote3
… listing the first three vendors (ordered by TableB.lastPurchasedDate desc) that are found for each TableA.partID. I am struggling to understand how to write a select statement for this (or coming up with the right terms in my Google searches). Would anyone be willing to push me in the right direction?
TableA
partID varchar(50) primary key
desc varchar(50)
uom varchar(2)
lastCost decimal
TableB
rowID int primary key
vendorID varchar(50)
partID varchar(50)
vendorPartID varchar(50)
quote decimal
lastPurchaseDate date
Thanks in advance,
Sheldon
TableA.partID, TableA.desc, TableA.uom, TableB.vendorID, TableB.quote, TableB.vendorID as vendorID2, TableB.quote as quote2, TableB.vendorID as vendorID3, TableB.quote as quote3
… listing the first three vendors (ordered by TableB.lastPurchasedDate desc) that are found for each TableA.partID. I am struggling to understand how to write a select statement for this (or coming up with the right terms in my Google searches). Would anyone be willing to push me in the right direction?
TableA
partID varchar(50) primary key
desc varchar(50)
uom varchar(2)
lastCost decimal
TableB
rowID int primary key
vendorID varchar(50)
partID varchar(50)
vendorPartID varchar(50)
quote decimal
lastPurchaseDate date
Thanks in advance,
Sheldon