oracle SQL 语句取周一到当前、本周、本月、本年的数据

本文介绍如何使用SQL查询特定时间段的数据,包括本周、本月和本年数据的筛选方法。通过具体的SQL语句示例,读者可以学习如何根据日期范围进行数据筛选。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

--查询本周周一到当天的数据
select * from table where time> sysdate - (to_char(sysdate,'D')-1)

--取本周时间内的数据
select * from table  where time>=trunc(next_day(sysdate-8,1)+1) and time<=trunc(next_day(sysdate-8,1)+7)+1 ;

 --国外的
select * from table  where time>=trunc(next_day(sysdate-8,1)) and time<=trunc(next_day(sysdate-8,1)+7);

--本月的
select * from table  where  time>=TRUNC(SYSDATE, 'MM')  and time<=last_day(SYSDATE);

--本年的
select * from table where to_char(time,'yyyy')=to_char(sysdate,'yyyy');
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值