I have two tables, proj: id name
and proj_reports: id, position, created_at, key_id, proj_id
and
I want to select from key_reports
for each proj_id
:
- total number of `key_id` which can be done with `count(.key_id)`
- total number of DISTINCT `key_id` `count(DISTINCT .key_id)`
- total number of `key_id` where `position` > 1
- total number of `key_id` where `position` > 2 AND < 5
The problem that I have is that I don't know how to add those conditions for checking if the position is > or < a number or in a range.