vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I'm fairly new to SQL and am having some difficulty with forming a query. I have these tables in my database: Table 1: items item_id item_name Table 2: events event_id item_id event_type date amount Table 'events' holds details of events associated with an item. Events are one of several types, given by event_type, and each event has a date and an amount. There can be many (or no) events of a given type for each item. I want to produce a query with these columns, with 1 row for each item_id: Item id Event_type1_earliest_date Event_type1_count (number of entries of this event type for this item id) Event_type1_total (sum of amounts for this event type for this item id) Event_type2_earliest_date Event_type2_count Event_type2_total ........(continuing for all event types) Could anyone point me in the right direction? Thanks. |