当前位置: 首页 > MySQL数据库

mysql如何自定义分析函数least及日期函数

时间:2026-01-28 14:11:11

mysql 自定义分析函数 least 及 日期函数

为项目需要,由于mysql不提供分析函数least ,自己写了一个.供大家参考.

SELECT filename,
      uarfcn,
      cpi,
      dateTime,
      str_to_date(dateTime, '%H:%i:%s.%f'),
      (select dateTime
         from tdoas_scantest_cellerr tt
        where tt.filename = t.filename
          and tt.uarfcn = t.uarfcn
          and tt.cpi = t.cpi
          and tt.id > t.id
        order by id limit 1) cc,
      time_to_sec(timediff(str_to_date(dateTime, '%H:%i:%s.%f'),
                           (str_to_date((select dateTime
                                          from tdoas_scantest_cellerr tt
                                         where tt.filename = t.filename
                                           and tt.uarfcn = t.uarfcn
                                           and tt.cpi = t.cpi
                                           and tt.id > t.id
                                         order by id limit 1),
                                        '%H:%i:%s.%f')))) cc2
 from tdoas_scantest_cellerr t
where filename = '0702-主干道珞瑜路-4-122K-3[1].SCL.txt'
  and cpi = 53
  and uarfcn = 10055
order by id

[@more@]

另附上部分日期函数

str_to_date  :将字符转日期

timediff  :取两个日期的差值

time_to_sec :将日期转为秒


上一篇:如何理解mysql自增长列
下一篇:如何理解MySQL SQL Profiler性能分析器
mysql least
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素