I have a query that returns images by a specific month (the min). The query works fine, except that the min never return NULL values, and i need the MIN to include NULL values. I understand that MIN does not return null values, that's why i've tried COALESCE, IFNULL, ISNULL and even LEAST, with no success..
Here's the query
SELECT i.published_date_year, i.published_date_month
FROM image i
JOIN (
SELECT i.published_date_year year, MIN(i.published_date_month) month
FROM image i
WHERE i.is_listed = 1
GROUP BY i.published_date_year
) t1 ON t1.year = i.published_date_year AND t1.month = i.published_date_month
WHERE i.published_date_year = 1967 AND i.is_listed = 1
ORDER BY i.published_date_year, i.published_date_month, i.published_date_day, i.image_id DESC
Notice
MIN(i.published_date_month)
I want to be able to return null values. Looks like MIN is not the correct function, so what is the correct function or formula?