I'm doing a join between tables, where I need to return all rows from the first table, however I use a where to limit in the date field, so I end up limiting my result to only the rows that belong to that date specifies, thus causing n to return all rows of the first table. In case, all the rows in the first table that are not on that date should return 0, does anyone give me a light how to do it?
I'm already using left outer join to get all the data in the first table.
select aa.nome_do_curso, count(cc.alunos_matriculados) contagem
from curso aa
left outer join id_aluno bb on aa.curso_ident = bb.curso_ident
left outer join matricula cc on bb.curso_registro = cc.curso_registro
left outer join periodo dd on cc.periodo_a = dd.periodo_a
where dd.data like '2006' or dd.data like '2007'
group by aa.nome_do_curso
order by 'contagem' desc
where data = varchar