How can I write the following query in SQL? I have a table where column B has erroneously been filled with duplicate values. The easiest way to find these duplicates is by comparing to another column A in the same table which should generally be a 1-to-1 correspondence, the table will possibly contain multiple rows of the repeated column B value
Something like this
column A | column B
-------------------
00234211 | T 156
00011331 | T 157
00011331 | T 157
04600100 | T 157 <--- This is probably an erroneous value, show me every row for "T 157"
07740010 | T 159
How would I write a SQL query resembling this terrible pseudo code
for all rows:
let A = columnA_value, B = columnB_value
for rows where columnA = A:
IF COUNT(columnB) > 1,
SHOW all rows WHERE columnA = A