Jump to content

Recommended Posts

Due to a poor database design, I'm having a dilemma with creating a chart of information on a webpage.  I'm going to try my best to be descriptive as possible. 

I have a table that holds information for events that people organize. My primary key is an auto-incremented program ID.  I need to create a page that displays the event holder's name along with the total points they have earned for holding each event, which I would have to do a SUM() for.  An example of the table would look like this, each row divided by a comma:

PID, NAME, EVENTNAME, POINTS
1, Alex, Pizza party, 50
2, Alex, Ice cream social, 100
3, Judy, Pizza party, 75
4, Jane, Movie night, 30

I need the webpage to display as follows:

Alex, 150
Judy, 75
Jane, 30

The page I need to create needs to list each person in the table along with a total of points that they have earned.  The problem I'm having is only naming Alex once, and adding up his points.  I figured the code snippet would look like something along the lines of:

SELECT NAME as name, SUM(POINTS) as points FROM TABLE;

Well obviously that won't work because of not being able to distinguish between names and who the points belong to.  So, I'm here to ask anyone if they have a solution to this problem.  I am a beginner when it comes to Oracle SQL and any help would be much appreciated. I am working in ColdFusion.

If I haven't been descriptive enough I will do my best to explain.  Thanks.
Link to comment
https://forums.phpfreaks.com/topic/17648-trouble-with-rows/
Share on other sites

  • 3 weeks later...
Just to add to what countnikon is saying, basically, you need a unique ID for the user, this could be an auto number although in database design, you would not set an auto number in the database, thats done in a database tier. Any way, all you would then do is query each ID, this will result in just a particular persons records being shown, you can then add the points togther using a loop. The problem is if you have a lot of users, then querying each user ID to calculate their points could become a big processing job. Hope that helps.
Link to comment
https://forums.phpfreaks.com/topic/17648-trouble-with-rows/#findComment-86556
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.