暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

oracle 查询近七天的数据

吼吼哈嘿 2025-02-15
127

–查询近七天产线名称为101的数据,并计算完成率

1、第一种用法,这种加条件的话不知道怎么加,但是百度了大多都是用这种方法,
SELECT lineid,to_char (SYSDATE- LEVEL + 1, 'yyyy-mm-dd') worktime,target,putout,100*round(putout/target,4)||'%' "实际完成率"
from YCZJ2 t
connect by level<7
--------
2、第二种用法
select lineid,sum(putout) as pro,target,worktime,100*round(sum(putout)/avg(target),4)||'%' as "完成率"
from YCZJ2
where worktime between to_char(sysdate - 6, 'mm-dd' )and to_char(sysdate, 'mm-dd') and lineid='101' group by worktime,target,lineid order by worktime desc

3、第三种用法
select lineid,putout,target,worktime,100*round(putout/target,4)||'%' as react
from YCZJ2
where worktime between to_char(sysdate - 7, 'mm-dd' )and to_char(sysdate-1, 'mm-dd') and lineid='101'
----
–查询近七个小时且产线为101的所有数据,并计算出完成率

select lineid,putout,worktime,target,100*round(putout/target,4)||'%' as react
from YCZJ
where lineid='101' and worktime between '11:30-12:30' and '17:30-18:30'and month1=to_char(sysdate,'mm') and day1=to_char(sysdate-1,'dd')
group by lineid,putout,worktime,target
order by day1 desc
------------
--计算百分比
select 100*round(putout/target,4)||'%' as "完成率"from BI_YCZJ_HOUR
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/KJJfighting/article/details/120922958

文章转载自吼吼哈嘿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论