I have the table:
ID | title1 | year1 | title2 | year2 | title3 | year3
5 | ghost | 2006 | runner | 2007 | alpha | 2008
5 | ghost | 2006 | runner | 2007 | beta | 2008
6 | Fight | 2007 | guard | 2008 | Jack | 2009
6 | Steam | 2010 | Pilot | 2011 | save | 2012
So I need a query that returns:
ID | title1 | year1 | title2 | year2 | title3 | year3
5 | ghost | 2006 | runner | 2007 | alpha | 2008
6 | Steam | 2010 | Pilot | 2011 | save | 2012
Best way of going about this? I was thinking of joining the table by itself and doing some operations but haven't had any luck.
the condition is that if ID has two different titles under the same year, then pick the title that comes first alphabetically, else pick the largest 3 consecutive years