Сначала выбираете доступные даты:
SELECT distinct P.date
FROM Query Q
JOIN Position P ON Q.id = P.query_id
where P.Date between _ and _
Потом, строите динамический запрос в той среде выполнения кода, где вызывали первый запрос:
SELECT Q.Query,
QP1.Cnt,
QP2.Cnt,
......
FROM Query Q JOIN Position P ON Q.id = P.query_id
left join (select Q1.Query, P1.Date, count(*) as Cnt from Query Q1 JOIN Position P1 ON Q1.id = P1.query_id group by Q1.Query, P1.Date) QP1 on QP1.Query = Q.uery and P1.Date = P.Date
left join (select Q2.Query, P2.Date, count(*) as Cnt from Query Q2 JOIN Position P2 ON Q2.id = P2.query_id group by Q2.Query, P2.Date) QP2 on QP2.Query = Q.Query and P1.Date = P.Date
....
where P.Date between _ and _
and (QP1.Cnt > 0 or QP1.Query is null)
and (QP2.Cnt > 0 or QP2.Query is null)
....
Строк в каждом секции с ... должно быть столько, сколько дат.