![]() |
Calculate show points in SQL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Calculate show points in SQL (/showthread.php?tid=91375) |
Calculate show points in SQL - HarmW94 - 07-31-2024 Hi, This query works now, but it needs to be more specific for the customer. I also looked to see if I can adjust the data in the (PHP) array, but I prefer to pull it out of the query so that sorting continues to work properly. I've been stuck on this part for a while now. SQL statements are not my specialty. Now it shows the total points well, but what I want to achieve is the following: It must count the points of the national show (type 1) first, since an animal participates in a national show a maximum of 1 time per year. Then it must select the 3 highest points and then stop counting (LIMIT). So when an animal has not yet participated in a national show, it takes the 3 highest scores and if one has participated, it still takes the 3 highest scores, but the national one must be above that. (show_participants.participant_category = "1" is now static, but this is for testing. There are 10 categories) Hope it's clear, thanks a lot in advance. Code: SELECT Sum(participant_match_points) AS participant_total_points, ![]() RE: Calculate show points in SQL - JustJohnQ - 08-03-2024 How about: Code: ORDER BY participant_total_points DESC, shows.show_type ASC ?? |