数据库表
TYPE DATE PLAYER MINUTE
---------------------------------------
starter 2000-01-01 Tom
starter 2005-01-01 Tom
starter 2005-01-01 Ben
starter 2010-01-01 Tom
subbedin 2012-01-01 Ben 46
询问
$query = mysql_query("SELECT *,
SUM(CASE WHEN type = 'starter' OR type = 'subbedin' THEN 1 ELSE 0 END) AS apps,
SUM(CASE WHEN Tüüp = 'starter' THEN 90 ELSE 0 end + CASE WHEN Tüüp = 'subbedin' THEN 91 - minutes ELSE 0 end) AS minutes
FROM players
GROUP BY player
ORDER BY apps DESC minutes DESC
");
我已经按照球员的出场次数和出场时间对结果进行了分组,但我无法让它显示第一次和最后一次出场的日期。
PLAYER APPS MINUTES FIRST LAST
-------------------------------------------------
Tom 3 270 2000-01-01 2010-01-01
Ben 2 135 2005-01-01 2012-01-01