I have the following scheme:
id | name | price | site_id | agency
1 | NAME | PRICE | 1 | AGENCY1
2 | NAME | PRICE | 1 | AGENCY1
3 | NAME | PRICE | 1 | AGENCY2
4 | NAME | PRICE | 1 | AGENCY2
5 | NAME | PRICE | 2 | AGENCY1
6 | NAME | PRICE | 2 | AGENCY1
7 | NAME | PRICE | 2 | AGENCY1
I want to get the first row with a unique agency for each site_id.
For example, the query result for the above scheme is expected to be:
1 | NAME | PRICE | 1 | AGENCY1
3 | NAME | PRICE | 1 | AGENCY2
5 | NAME | PRICE | 2 | AGENCY1
I have tried to look for solutions with DISTINCT but couldn't figure it out.