Thanks Rudy, I don’t think I was clear and you thought I wanted to output a null if I didn’t have ‘any’ data for a particular date? I actually need to output a null if I don’t have a value for the id/date combination.
SELECT team.id
, dates.the_date
, ranking.pos
FROM team
CROSS
JOIN ( SELECT DATE('2013-02-01')
+ INTERVAL n DAY AS the_date
FROM numbers
WHERE DATE('2013-02-01') + INTERVAL n DAY
< DATE('2013-03-01')
) AS dates
LEFT OUTER
JOIN ranking
ON ranking.id = team.id
AND ranking.date = dates.the_date
Fantastic Rudy. I don’t think I’d have ever got that. Thanks once again for your help - it’s not the first time you’ve helped me with a tricky bit of SQL