PostgreSQL问题-如何计算唯一性和不唯一性?

时间:2018-09-04 18:19:23

标签: postgresql

我正在尝试找出如何通过唯一ID(每个ID仅包含一个ID)SUM的时间。这是一些数据的标记。我需要GROUP BY f_namel_namearea。我还需要组计数(唯一编号的id)和组参与者(仅简单编号的id):

+----+------+-------+-------+------+--+
| ID | Time | fname | lname | Area |  |
+----+------+-------+-------+------+--+
|  1 | 3:30 | Jeff  | Chose | LA   |  |
|  1 | 3:30 | Jeff  | Chose | LA   |  |
|  1 | 3:30 | Jeff  | Chose | LA   |  |
|  2 | 4:00 | Jeff  | Chose | LA   |  |
+----+------+-------+-------+------+--+

数据应如下所示:

+------+-------+-------+------+-------------+--------------------+
| Time | fname | lnam  | Area | Group Count | Group Participants |
+------+-------+-------+------+-------------+--------------------+
| 7:30 | Jeff  | Chose | LA   |           2 |                  4 |
|      |       |       |      |             |                    |
+------+-------+-------+------+-------------+--------------------+

奖金:如果您可以将3:30转换为3.5

0 个答案:

没有答案