You don't need a JOIN to get the result, you should be able to get it by using a CASE expression inside of your aggregate function:
SELECT
DATE(datetimebegin) AS Date,
sum(case when problemID = '1' then 1 else 0 end) AS CntProb1,
sum(case when problemID = '2' then 1 else 0 end) AS CntProb2
FROM `problems`
WHERE problemID in ('1', '2')
GROUP BY DATE(datetimebegin);
If you want to use count()
instead of sum()
then you would use:
SELECT
DATE(datetimebegin) AS Date,
count(case when problemID = '1' then problemID end) AS CntProb1,
count(case when problemID = '2' then problemID end) AS CntProb2
FROM `problems`
WHERE problemID in ('1', '2')
GROUP BY DATE(datetimebegin);
See SQL Fiddle with Demo of both queries.