加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

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

发布时间:2021-12-18 13:15:41 所属栏目:MySql教程 来源:互联网
导读:mysql如何自定义分析函数least及日期函数,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。 mysql 自定义分析函数 least 及 日期函数 为项目需要,由于mysql不提供分析函数least ,自己
mysql如何自定义分析函数least及日期函数,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
 
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如何自定义分析函数least及日期函数问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
mysql如何自定义分析函数least及日期函数

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读