sql-两个列的计数

时间:2019-01-09 10:37:23

标签: mysql sql mariadb grafana

我在数据库中放了很多行,我有这个:

+----+---------------------+-------------+----------------+-----------+
| ID | time                | os_name     | program        | last_line |
+----+---------------------+-------------+----------------+-----------+
| 14 | 2019-01-04 14:00:00 | titi        | roro           | 109       |
| 15 | 2019-01-04 14:00:00 | titi        | roro           | 109       |
| 16 | 2019-01-04 14:00:00 | gege        | fefe           | 109       | 

我想要:

+---------------------+-------------------------+-------------+-----------+-----------+
| time                | nb_os_name_program      | os_name     | program   | last_line |
+---------------------+-------------------------+-------------+-----------+-----------+
| 2019-01-04 14:00:00 |                      2  | titi        | roro      | 109       |
| 2019-01-04 14:00:00 |                      1  | gege        | fefe      | 109       | 

1 个答案:

答案 0 :(得分:0)

简单的def findDataPath(self, filename): """ Get the correct path for outside data works with cx_freeze :params str filename: the filename looking for :returns: the absolute path of the file. :rtype: string """ p = os.path.dirname((os.path.dirname(os.path.abspath(__file__))) p = os.path.join(p, filename) return p 聚合会为您提供帮助:

GROUP BY
相关问题