Quantcast
Viewing latest article 8
Browse Latest Browse All 4871

How to get common values from multiple tables but keep the row count the same?

need common values from the four tables that occur only as many times they do in one table that is Library

I want the PartRn and PartNumber, Rev, and the Max return date for the records in the Library table. The rows in the Library should be exactly the. The issue when any type of Join is done the rows duplicate as many times they occur in the other table. In Library Transaction MAFN=850 occurs 3 times. A join(left, or inner) will result in 3 rows in the end result.

What I have tried:

Make a CTE called CommonPartRn to get the common records between Parts and PartsRev tables.Make 2 CTE's where I assign the Row Numbers ordered by Mafn in Library table, LibraryCTE. Create another CTE LibraryTransactionsCTE with row number assigned by MAFN and ordered by ReturnDt (DESC) in the LIbrary Transaction table.Join these 3 CTEs to get and filter by...

Viewing latest article 8
Browse Latest Browse All 4871

Trending Articles