So I have an example table called items with the following columns:
- item_id (int)
- person_id (int)
- item_name (varchar)
- item_type (varchar) - examples: "news", "event", "document"
- item_date (datetime)
...and a table person with the following columns: "person_id", "person_name".
I was hoping to display a list of the top 2 submitters (+ the COUNT() of items submitted) in a given time period for each item_type. Here's basically what I was hoping the MySQL output would look like:
person_name | item_type | item_count
Steve Jobs | document | 11
Bill Gates | document | 6
John Doe | event | 4
John Smith | event | 2
Bill Jones | news | 24
Bill Nye | news | 21
How is this possible without making a separate query for each item_type? Thanks in advance!