0

我需要编写一个 sql 语句来获取表中每天的 WPM 计数。几天内会有多个条目;我只需要最高的 WPM。此外,不包括空条目。

The data set should look like:
Date_completed, Max_WPM
date here, wpm
date here, wpm

SELECT 
       DISTINCT A.DATE_COMPLETED
            ,A.WPM Max_WPM
FROM KEYBOARD_LEARNING A

我正在尝试过滤此表的结果集中仅返回不同日期的位置。但是上面的查询不起作用。如何使用 WPM 返回不同的日期?

DATE_completed    MAX_WPM
--------------------------     ---------------
7/12/2012                ...
7/12/2012                ....
7/12/2012
7/22/2012
7/6/2012
7/12/2012
7/12/2012
7/6/2012
7/12/2012
7/12/2012
7/6/2012
7/6/2012
6/13/2012
7/12/2012
7/12/2012
7/16/2012
6/6/2012
7/6/2012
7/6/2012
6/12/2012
6/13/2012
7/6/2012
7/6/2012
7/6/2012
7/12/2012
6/13/2012
7/4/2012
6/14/2012
7/6/2012
4

1 回答 1

1

听起来你想要

SELECT A.DATE_COMPLETED
      ,MAX(A.WPM) Max_WPM
  FROM KEYBOARD_LEARNING A
 WHERE a.wpm IS NOT NULL
 GROUP BY a.date_completed

这假设没有任何DATE_COMPLETED值具有时间分量。如果是这样,您需要TRUNC日期

SELECT TRUNC(A.DATE_COMPLETED) date_completed
      ,MAX(A.WPM) Max_WPM
  FROM KEYBOARD_LEARNING A
 WHERE a.wpm IS NOT NULL
 GROUP BY TRUNC(a.date_completed)
于 2012-07-23T21:42:20.993 回答