I am trying to list the entire task with a count of the completed / completed task (in the materials). The problem is that I also want to show the whole task that users have not completed. This query does not list count = 0 (Null). Is there any way to do this?
Required Result:
Date | title | completed 2014-05-20 | Case 1 | 45 2014-05-24 | Case 10 | 11 2014-05-20 | Case 2 | 0
I have tried so far:
Select date, title, count(*) as completed from users u, submissions s, task t where u.userPK = s.user and s.task= t.taskPK group by taskPK order by completed desc;
I think you can achieve this using LEFT JOIN:
LEFT JOIN
SELECT date, title, COUNT(u.userPK) completed FROM task t LEFT JOIN submissions s ON s.task = t.taskPK LEFT JOIN users u ON s.user = u.userPK GROUP BY t.taskPK ORDER BY completed;
OUTER JOIN. , , , , GROUP BY taskPK, date title.
OUTER JOIN
GROUP BY
taskPK
date
title
, , :
SELECT t.date, t.title, count(*) cnt FROM task t LEFT JOIN submissions s ON t.task = s.taskPK GROUP BY t.date, t.title ORDER BY cnt DESC
user, , . , .
user
Source: https://habr.com/ru/post/1542403/More articles:"AngularJS method" for displaying values ββfor output in a view - angularjsQThread :: quit () immediately terminates the thread, or does it wait until it returns to the event loop? - c ++Owncloud not available after installation on Ubuntu 14.04 server - phpHow to parallelize std :: partition using TBB - c ++ΠΡΠ±ΡΠΎΡ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ Π±ΠΎΠ»Π΅Π΅ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΡΠ°Π·Π° ΡΠ΅ΡΡΠ΅Ρ ΠΈΡΡ ΠΎΠ΄Π½ΡΡ ΡΡΠ°ΡΡΠΈΡΠΎΠ²ΠΊΡ ΡΡΠ΅ΠΊΠ° - c#ΠΡΠΊΠ»ΡΡΠΈΡΡ ΡΠ°Π·ΡΠ΅ΡΠ΅Π½ΠΈΠ΅ ΡΠ΅ΡΡΠΎΠ²ΠΎΠΉ Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΎΡ `sbt compile` - scalaFind data elements in a data frame that pass a rule for a node in a tree model? - rAre Unicode characters valid in variable names? - javascriptshutl.rmtree does not work with windows library - pythonΠ‘++. ΠΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ, ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ ΠΊΠΎΠΏΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΈ ΠΈΠ½ΠΈΡΠΈΠ°Π»ΠΈΠ·Π°ΡΠΈΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ. - c++All Articles