I have a simple question: How can I use having Count(Distinct) in SQL (Oracle to be exact) to return only the rows where there are 2 column with same record but 1 column with different record.
Example
CA_ID BA_ID SA_ID
---- ----- --------
CA1 BA1 SA1
CA1 BA2 SA1
CA1 BA2 SA2
CA1 BA3 SA1
CA2 BA4 SA3
CA2 BA4 SA4
CA2 BA5 SA4
CA3 BA6 SA6
In that example, i'd like to create a query that shows 1 same CA_ID and SA_ID, but has different BA_ID. The query's result should show like this
CA_ID BA_ID SA_ID
---- ----- --------
CA1 BA1 SA1
CA1 BA2 SA1
CA1 BA3 SA1
CA2 BA4 SA4
CA2 BA5 SA4