Answer the question
In order to leave comments, you need to log in
How to display the number of rows 0 if there are none in the selection?
For the standings, you need to make a view (view) of all the defeats of the team.
I have 16 teams, of which one team has never lost, the rest have lost at least once. At the request below, I display those teams that lost, that is, 15 pieces.
How can you also display the team that has no defeats and so that its value is 0?
select `vw_games`.`ID_TEAM` AS `ID_TEAM`,count(`vw_games`.`ID_TEAM`) AS `Losses` from `test`.`vw_games` where (`vw_games`.`RESULT` < 0) group by `vw_games`.`ID_TEAM`
Answer the question
In order to leave comments, you need to log in
SELECT (SELECT COUNT(*) FROM vw_games AS g WHERE g.ID_TEAM=t.ID_TEAM AND `vw_games`.`RESULT` < 0)
FROM Teams AS t
ps. Teams is your team table, do you have it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question