I have two tables:
categories => Category_ID, Title, Description, Default_Points, Groups
transactions => Transaction_ID, Datetime, Giver_ID, Recipient_ID, Points, Category_ID, Reason
Teachers award points, choosing a category (like "Positive Attitude & Behaviour") and a reason (like "Excellent work today") which puts an entry into the transactions table.
A typical categories row may be:
INSERT INTO `categories` (`Category_ID`, `Title`, `Description`, `Default_Points`, `Groups`) VALUES
(17, 'Olympic Values', 'Please clearly state the correct Olympic Value that''s being used currently in the REASON box.', 5, '');
A typical transactions row may be:
INSERT INTO `transactions` (`Transaction_ID`, `Datetime`, `Giver_ID`, `Recipient_ID`, `Points`, `Category_ID`, `Reason`) VALUES
(50, '2011-09-07', 35023, 90236, 5, 17, 'Excellent work during PE');
What I'd like to try and do using MySQL is produce a list of total points (i.e. SUM(transactions.Points) for EACH category, with a few sample Reasons too.
I'd imagine this will have to use a CONCAT?
I need:
SUM(transactions.Points)per categorycategories.title- 5 unique
transactions.reasonper category
This might look like...
Points Title Sample
14252 Olympic Values Excellent work in PE!|Great display of friendship|Well done!
15532 Outstanding Effort Amazing work!|Worked so hard|Great piece!
Is this possible?
Thanks in advance,