Database Help

Hello All,

I am working on a web application for a client which is a reporting system.

They have a system they want to run reports on the system has a table

tickets with columns ticketid and departmentid

and a table

ticketposts with columns ticketid(foreign key) and staffid

I want to be able to count how many total tickets there are grouped by department id as well as count how many ticketposts there were for a specific departmentid(the department id is not in the ticketposts table) if the column staffid is greater than 0(is a staff member)

Thanks