SQL: Selecting the min and max values but with combinations where there
are more than 2 values
Okay so i'm trying to write a query that returns the max and min of dates
of things that have been repeated. So if a particular movie was made 3
times at the dates of 1982, 1999 and 2001, the query would return:
Title : Min : Max
movietitle1 : 1982 : 2001
movietitle1 : 1982 : 1999
movietitle1 : 1999 : 2001
since there are 3 possible combinations, there are 3 results. If a movie
was only made twice then it was just show the first date, and the last
date.
Title : Min : Max
movietitle2 : 1960 : 2006
This is the query i have right now, unfortunately it only shows the min
and max and disregards any possible 3rd value. It also can't used GROUP BY
since i'm not summarizing data:
SELECT name, MIN(releaseyear), MAX(releaseyear)
FROM movielist
HAVING MAX(releaseyear) != MIN(releaseyear)