我想在列中找到最小值,但仅限于行中的日期大于指定日期。我正在使用此查询:
select
T.`teamId`,
T. `teamName` as winnerName,
X.teamid,
X.teamName as loserName,
date_format(`gameDate`,"%M %D") as date,
`IMPmargin` as MinIMPs
FROM `vichill_games-2` G
join `vichill_teams-2` as T on (G.winner = T.`teamid`)
join `vichill_teams-2` as X on (G.loser = X.`teamid`)
WHERE `IMPmargin` = (SELECT MIN(NULLIF(`IMPmargin`, 0)) FROM `vichill_games-2` WHERE `gameDate` > "2014-10-01" )
查询返回:
teamId winnerName teamid loserName date MinIMPs
22 Boyd 26 Ellis October 1st 14
28 Wolford 27 Ogan October 15th 14
22 Boyd 27 Ogan October 1st 14
在某种程度上可以看到gameDate测试。如果我的日期晚于任何游戏的日期,则不会按预期返回任何内容。
我认为我在错误的地方进行了gameDate测试,但我无法弄清楚。
我们很乐意接受有关查询的任何建议,或让我了解更多信息的资源。
感谢。
比尔