Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:03:37+00:00 2026-05-31T01:03:37+00:00

I have two tables: categories => Category_ID , Title , Description , Default_Points ,

  • 0

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 category
  • categories.title
  • 5 unique transactions.reason per 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,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:03:38+00:00Added an answer on May 31, 2026 at 1:03 am

    It’s GROUP_CONCAT you want.

    You’ll need to do something like this:

    SELECT SUM(t.Points), 
        c.title, 
        SUBSTRING_INDEX(GROUP_CONCAT(transactions.reasons SEPERATOR '|'), '|', 5)
    FROM transactions t JOIN categories c ON (t.Category_ID=c.Category_ID)
    GROUP BY c.Category_ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables called categories and topics. categories has columns category_id and category_title.
I have a two tables, Post and categories, Post have category_id I can get
I have two tables for an online shop: one for categories: id, title one
I have two tables, movies and categories , and I want to get an
Say I have two tables I want to join. Categories: id name ---------- 1
We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType
Let's assume I have a database with two tables: categories and articles . Every
I have two tables, products and categories which have a many to many relationship,
I have two tables, categories and products. I am using CodeIgniter. Categories CREATE TABLE
I have two tables: Category (Id, Name, ...) and Question (Id, CategoryId, Title, ...)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.