mysql和 oracle计算两个时间之间相差几分钟

本文深入探讨了SQL查询语句的高级用法,包括复杂的联接操作、条件筛选及时间戳处理技巧。通过实例,详细解析了如何从多个表中高效获取所需数据,以及如何精确处理日期和时间,为数据库管理和数据分析提供了实用的解决方案。
摘要由CSDN通过智能技术生成
​
 select a.*,e.name workshop,d.code devicecode,b.orderchildno,c.code productcode,c.name productname,f.code moldcode,f.name moldname,
    k.name as CheckStateDsp,j.name as CheckResultDsp,b.quantity as orderquantity,l.name factoryname,g.description shiftname,
		case when a.CheckEndTime is null then null else
		ceil(round(to_number(a.CheckEndTime-a.CheckStartTime)*24*60,2)) end CheckTimeDiff,to_char(a.senttime,'yyyy-mm-dd hh24:mi:ss') senttimedesp,
		to_char(a.checkstarttime,'yyyy-mm-dd hh24:mi:ss') checkstarttimedesp,
		to_char(a.checkendtime,'yyyy-mm-dd hh24:mi:ss') checkendtimedesp
        from  biz_qa_check_first a
    inner join biz_order_child b on a.orderchildid = b.id
    inner join biz_product c on b.productcode = c.code and b.factoryid = c.factoryid
    left join biz_dev_injector d on a.deviceid = d.id
    left join biz_base_workshop e on d.workshop = e.id
    left join biz_mold f on a.moldid = f.id
    left join biz_base_shift g on a.shift = g.CODE and a.factoryid = g.factoryid
    left join v_sys_dict j on a.checkresult = j.code and j.pcode = 'QaCheckResult' and j.type = ''
    left join v_sys_dict k on a.state = k.code and k.pcode = 'CheckStatus' and k.type = ''
    left join biz_base_factory l on l.id = a.factoryid
    where a.state !='csNew'
    and a.senttime >=	to_date('${checkstarttime} 00:00:00','yyyy-mm-dd hh24:mi:ss')
    and a.senttime <= to_date('${checkendtime} 23:59:59','yyyy-mm-dd hh24:mi:ss')
    order by a.senttime DESC,d.id,sequenceno desc
​
​
select a.*,e.name workshop,d.code devicecode,b.orderchildno,c.code productcode,c.name productname,f.code moldcode,f.name moldname,
    k.name as CheckStateDsp,j.name as CheckResultDsp,b.quantity as orderquantity,l.name factoryname,g.description shiftname,
    if(a.checkendtime=null,null,ceil(TIMESTAMPDIFF(SECOND,a.CheckStartTime,a.CheckEndTime)/60)) CheckTimeDiff
    ,DATE_FORMAT(a.senttime,'%Y-%m-%d %H:%i:%s') senttimedesp,
    DATE_FORMAT(a.checkstarttime,'%Y-%m-%d %H:%i:%s') checkstarttimedesp,
    DATE_FORMAT(a.checkendtime,'%Y-%m-%d %H:%i:%s') checkendtimedesp
      from  biz_qa_check_first a
    inner join biz_order_child b on a.orderchildid = b.id
    inner join biz_product c on b.productcode = c.code and b.factoryid = c.factoryid
    left join biz_dev_injector d on a.deviceid = d.id
    left join biz_base_workshop e on d.workshop = e.id
    left join biz_mold f on a.moldid = f.id
    left join biz_base_shift g on a.shift = g.CODE and a.factoryid = g.factoryid
    left join v_sys_dict j on a.checkresult = j.code and j.pcode = 'QaCheckResult' and j.type = ''
    left join v_sys_dict k on a.state = k.code and k.pcode = 'CheckStatus' and k.type = ''
    left join biz_base_factory l on l.id = a.factoryid
    where a.state !='csNew'

​​​​​​​​​​​​​​​​​​​​​​​​在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值