SELECT MAX(crash_year) AS crash_year, COUNT(crash_year) AS COUNT
FROM nyccrash
GROUP BY crash_year
ORDER BY COUNT(crash_year) DESC;
此聲明將返回整個範圍20年。但是,我如何檢索第一行?找到具有最高崩潰率的年份?
+------------+-------+
| crash_year | count |
+------------+-------+
| 1999 | 862 |
| 1990 | 847 |
| 1992 | 812 |
| 1991 | 810 |
| 1993 | 806 |
| 2000 | 803 |
| 1994 | 782 |
| 1989 | 763 |
| 2001 | 729 |
| 1995 | 698 |
| 1997 | 672 |
| 1996 | 671 |
| 1998 | 665 |
| 2002 | 497 |
| 2003 | 419 |
| 2006 | 384 |
| 2004 | 377 |
| 2007 | 364 |
| 2005 | 363 |
+------------+-------+
謝謝你,忘了極限的事情。 – 2012-04-05 03:01:28