MySQL Forums
Forum List  »  Newbie

Two MIN and MAX queries
Posted by: B R
Date: June 04, 2021 12:23AM

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?

Options: ReplyQuote


Subject
Written By
Posted
Two MIN and MAX queries
B R
June 04, 2021 12:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.