Suppose I’ve got a table:
Role ---- person_id company_id financial_year
How can I tell the following:
- Whether each person_id occurs at most once per company_id per financial_year in this table
- If 1. is false, which person_id’s and company_id’s and financial_year’s co-occur more than once
Edit 1: Edited to add financial_year col
Edit 2: the RDBMS platform here happens to be MySQL, though I don’t expect that this would require much vendor-specific SQL
For the first, it’s generally a good idea to just have a grouping which you can then filter on if you want:
For the second, you can just modify the above like so: