I need a query that can compare two columns (DBVersionKey, Desc19). Logic - If the same Desc19 is used for more than one DBVersionKey, return only those results. Below is the data range (snippet)
DATA SAMPLE
DBVersionKey Desc19
2491 W25170206H
2492 W25170212H
2493 W25170218H
2494 W25170224H
9129 40761KB18X
9191 40761KB18X
EXPECTED RESULT
DBVersionKey Desc19
9129 40761KB18X
9191 40761KB18X
*I have tried GROUP BY, HAVING COUNT and many other theory solutions
I do not want the query to contain any specifics to the data values, due to a potential high volume of affected records
Table name - Table_A
I suggest using common table expressions with row number partitions. This creates a count (RN) of each instance of Desc19.
I can't test the query right now, but keep me updated on your results and I can adjust from there.
EDIT
If DBVersionKey is not a unique value, I would try:
Let me know if that works better.
EDIT 2
One again, I can't test it. Adding to the first suggested query:
Correct solution based on EDIT 2 by alybaba726