ViperSBT Posted April 22, 2007 Share Posted April 22, 2007 OK, I tried for awhile to come up with a reasonable Subject that explained what I was looking to do, but couldn't. So here it is: I have a table that is loaded with competition results. These results are fairly simplistic being that the table consists primarily of the competitor number and the points the competitor earned at a particular event. So the four fields are 'id', 'competitor', 'event', 'points'. A competitor will be listed multiple times in the this table, based upon its entries in multiple events and the points earned for each of those events. Now for the tricky part. When doing reporting, I query this table by competitor to get a listing of all events the competitor entered as well as the points earned for each event, and I can sort this by the event so it shows chronologically the points the competitor earned. The thing that I am trying to figure out, is how to identify which event a competitor crossed a certain point level. As an example, I want to know which event a competitor earned their 5,000th point. I would like to be able to do this as part of the query, is it possible, or will it have to be done in PHP after the query is returned? Quote Link to comment https://forums.phpfreaks.com/topic/48195-solved-i-dont-know/ Share on other sites More sharing options...
bubblegum.anarchy Posted April 23, 2007 Share Posted April 23, 2007 hmm... possibly: SELECT * FROM ( SELECT ifnull(@n:=@n+points, @n:=1) as points_aggregate, tbl_name.* FROM tbl_name ) AS points_table WHERE points_aggregate > 5000 LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/48195-solved-i-dont-know/#findComment-235647 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.