I've got a MYSQL query. Selecting FROM a 'matchResults 'table but some fields are coming from matchData, teamData tables.
In my matchResults table I have resultDate.
Currently this is part of my query which works nicely.
SELECT DISTINCT rd.playerId, t.teamName, t.teamId, MIN(rd.resultDate) as FD, MAX(rd.resultDate) as LD,
Where FD and LD are finding the first and last dates for a team when the teamId is given in the WHERE clause.
Some results (game outcomes) have a indicator on them, indicating the match was played for a shield. the Column is called 'margsResult' which is either 1 or 0.
I'm trying to also result the first and last dates of these matches. Tried doing this.
CASE WHEN g.margsResult = 1 THEN MIN(rd.resultDate) ELSE 0 END as FTG,
But I still get the lowest or earliest date.
Any ideas?