-
Notifications
You must be signed in to change notification settings - Fork 1
Show drivers page are showing drivers several times #28
Comments
@inguni @stmeissner Can any of you modify array to resolve this issue? I've been a week and I have not got it, I even tried with:
|
@arv187 could you please provide some sample data to reproduce this issue? Thanks |
Of course! |
@arv187 I think I know what you are after; try adding this to the end of the queries: |
Not,
When I make "group by" I lost the second entry. So first you have to do a count by position, I think something like this or another better option with arrays. $sql_first_position = "SELECT And you should get:
I think that actual array its bad to achieve this goal, see 4-7 and 42-51 lines. |
@arv187 this can be done on SQL level. CREATE VIEW team_driver_top3 AS
SELECT team_driver,
sum(case when position = 1 then 1 else 0 end) as position_1_count,
sum(case when position = 2 then 1 else 0 end) as position_2_count,
sum(case when position = 3 then 1 else 0 end) as position_3_count
from race_driver
group by team_driver
order by position_1_count desc and this is its content:
That view still contains separate rows for drivers running for more than one team. SELECT name,
SUM(position_1_count) AS pos_1,
SUM(position_2_count) AS pos_2,
SUM(position_3_count) AS pos_3
FROM team_driver, team_driver_top3, driver
WHERE (team_driver.id = team_driver_top3.team_driver AND team_driver.driver = driver.id)
GROUP BY driver
ORDER BY pos_1 DESC, pos_2 DESC, pos_3 DESC; leading to this result:
Is this what you want to see? |
@stmeissner YES!!!!! that is, thank you very much!!! Once I got it with the sql console, but I was not able to put it together in php with the team_driver table and driver (which contains the names and image of the pilot when it is registered). I was getting lost with the array and php. Again, thank you so much for your help. |
Fixed by @stmeissner in pull request #44 Thank you!! |
show_drivers.php http://prem.hol.es/prem/?page=show_drivers
It is showing drivers as many times as teams have or had.
If a pilot have 2 teams the pilot is showed two times.
Ideal solution will show the pilot only one time GROUP BY driver.id, with the COUNT of all podiums from all their teams (including historical teams in his career).
The text was updated successfully, but these errors were encountered: