I have a SQL problem. my query looks like:
Select
s.idseminar, count(p.seminar)
From
Seminar as s
LEFT OUTER JOIN
Predbiljezba AS p ON p.seminar = s.idSeminar
WHERE
p.obradjena = 1
Group by
s.idSeminar
idseminar: 1, 2
count....: 2, 2
It should display number of accepted applications (predbiljezba with obradjena = 1 <== accepted status) for courses (seminar). It does almost what I need.
What I want is for it to display all the courses even if the number of accepted subscriptions is 0. If I omit the where clause:
Select
s.idseminar, count(p.seminar)
From
Seminar as s
LEFT OUTER JOIN
Predbiljezba AS p ON p.seminar = s.idSeminar
Group by
s.idSeminar
idSeminar: 1,2,3,4
count....: 2,2,1,0
it displays all the courses even if it it has 0 applications, but in these applications there are some that were not processed or were rejected and I do not want them to pop up in my query. I’ve found this link
Displaying rows in SQL Server where COUNT = 0
but the solution there doesn’t seem to work. I’m using SQL Server 2012.
You can use subselect in the main select clause