I have a problem that I need to select all owners who have 2 different companies where each company is on 2 different projects.
For example :
owner company project
1 company1 project1
1 company1 project2
1 company2 project2
1 company2 project3
1 company2 project1
2 company1 project1
2 company2 project1
2 company3 project1
2 company3 project2
3 company2 project2
3 company1 project1
I tried to do like this :
select owner from table
group by owner
having count(distinct company)>1 and count(distinct project)>1
But it did not work.
How to use a SQL query to solve this problem? For this case above, the query is expected to return:
1