Here I have a table that has many rows and I ultimately want a final result where the rows are output based off of matching criteria. I would like to extract the Rows / or Col1 where Code includes values '1' and '3' together. I was looking to also add DISTINCT but not sure if needed because the initial table has many duplicate rows.
Col1 | Col2 | Code |
---|---|---|
A | 132 | 1 |
A | 132 | 3 |
B | 141 | 3 |
C | 149 | 2 |
D | 100 | 7 |
The table would look like the table below:
Col1 | Col2 | Code |
---|---|---|
A | 132 | 1 |
A | 132 | 3 |
Edit. I've tried code similar to this from another posting. I modified it to cater to what I was looking for but was getting an error when using having and found the results were missing some rows I was expecting. SELECTING with multiple WHERE conditions on same column
SELECT T1.contact_id FROM your_table T1 JOIN your_table T2 ON T1.contact_id = T2.contact_id AND T2.flag = 'Uploaded' -- // more joins if necessary WHERE T1.flag = 'Volunteer'