It is some rather complicated queries which are needed to obtain those data. You could use the sourceone reporting pack for it. That would be the easiest way to get it.
It is part of the base license
SourceOne Reporting is the best way to go.
You can refer to SourceOne Admin Guide and Installation Guide for more information.
Were you able to find the SQL query?
Could you please share, because I am also looking for the same information.