theINTERN Posted August 15, 2006 Share Posted August 15, 2006 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, POINTS1, Alex, Pizza party, 502, Alex, Ice cream social, 1003, Judy, Pizza party, 754, Jane, Movie night, 30I need the webpage to display as follows:Alex, 150Judy, 75Jane, 30The 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 More sharing options...
countnikon Posted August 30, 2006 Share Posted August 30, 2006 I would add another field in there that is a unique userID. That would solve the problem real quick if you don't have very many records yet. Link to comment https://forums.phpfreaks.com/topic/17648-trouble-with-rows/#findComment-83059 Share on other sites More sharing options...
syed Posted September 5, 2006 Share Posted September 5, 2006 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.