select * from blog_log;
+----+---------------------+-------+--------+
| id | time | level | info |
+----+---------------------+-------+--------+
| 1 | 2011-11-11 23:32:32 | 1 | haha |
| 2 | 2012-12-12 12:21:21 | 1 | haha |
| 3 | 2013-12-12 12:12:12 | 1 | hehe |
| 4 | 2013-02-12 12:12:12 | 2 | haha |
| 5 | 2013-12-02 12:12:12 | 2 | hehe |
| 6 | 2013-12-02 13:12:12 | 2 | hehe |
| 7 | 2016-12-02 12:12:12 | 2 | hehe |
| 8 | 2013-12-25 12:12:12 | 1 | haha |
| 9 | 2011-11-11 23:32:32 | 3 | hahage |
| 10 | 2001-11-11 23:32:32 | 5 | hahage |
+----+---------------------+-------+--------+

 

SELECT level, info, GROUP_CONCAT(time ORDER BY time DESC SEPARATOR " | ") AS time, COUNT(1) AS count FROM blog_log GROUP BY level, info ORDER BY time DESC, count DESC
-> ;
+-------+--------+-----------------------------------------------------------------+-------+
| level | info | time | count |
+-------+--------+-----------------------------------------------------------------+-------+
| 2 | hehe | 2016-12-02 12:12:12 | 2013-12-02 13:12:12 | 2013-12-02 12:12:12 | 3 |
| 1 | haha | 2013-12-25 12:12:12 | 2012-12-12 12:21:21 | 2011-11-11 23:32:32 | 3 |
| 1 | hehe | 2013-12-12 12:12:12 | 1 |
| 2 | haha | 2013-02-12 12:12:12 | 1 |
| 3 | hahage | 2011-11-11 23:32:32 | 1 |
| 5 | hahage | 2001-11-11 23:32:32 | 1 |
+-------+--------+-----------------------------------------------------------------+-------+

相关文章:

  • 2021-12-31
  • 2022-12-23
  • 2022-02-21
  • 2021-10-16
  • 2021-04-23
  • 2021-07-01
猜你喜欢
  • 2021-06-24
  • 2022-12-23
  • 2021-10-03
  • 2021-05-15
  • 2021-11-07
  • 2022-01-16
相关资源
相似解决方案