Monatsliste mit left Join ?

Werbung:
Hab es, die Lösung war etwas komplizierter:

select x.name, count(x.rvzurueckam) as anzahl1, count(x.datum) as anzahl2
from
(SELECT *
FROM (SELECT monatid, name FROM tabmonate) AS s LEFT JOIN (SELECT rvzurueckam, datum FROM tabplanung) AS c1 ON s.monatid = month(c1.RVzurueckAm)
WHERE (Year(c1.rvzurueckam) Is Null Or Year(c1.rvzurueckam)="2015")
ORDER BY s.monatid
union
SELECT *
FROM (SELECT monatid, name FROM tabmonate) AS s left join (SELECT rvzurueckam, datum FROM tabplanung) AS c2 ON s.monatid = month(c2.datum)
WHERE (Year(c2.datum) Is Null Or Year(c2.datum)="2015")
ORDER BY s.monatid) as x
group by x.name,x.monatid
order by x.monatid
 
Zurück
Oben