Tickets Statistics


I am building a simple dashboard which lists various stats about the open tickets. I am trying to pull out the following data programatically for reporting purposes:

* The total number of all tickets
* The total number open tickets
* The total number of closed tickets
* Total number of open tickets per client
* Total number of open tickets per user

Help would be greatly appreciated. What is the best way to pull out this info from the database?

Many thanks.