
WHERE sendtime >= DATE_SUB( CURRENT_DATE() , INTERVAL 3 MONTH )
1、创建测试表,create table test_date2(id number, v_date date)
2、插入测试数据,
insert into test_date2
select level, sysdate - level * 2 from dual connect by level <100
3、查看表中所有记录,select t.* , rowid from test_date2 t
4、编写sql代码,取近三个月数据,用add_months函数
select t.*, rowid from test_date2 t where v_date >add_months(sysdate, -3)
5、编写sql代码,取近10天数据,用sysdate-10函数,
select t.*, rowid from test_date2 t
where v_date >sysdate-10 order by v_date
mysql中怎么查询一周内,三个月内\x0d\x0a使用sql语句查询日期在一周内的数据\x0d\x0aselect * from ShopOrder where datediff(week,ordTime,getdate()-1)=0 //查询当天日期在一周年的数据\x0d\x0aselect * from ShopOrder where datediff(day,ordTime,getdate()-1)=0 //查询当天的所有数据\x0d\x0a SELECT * FROM A where datediff(d,datetime,getdate()) 回答于 2022-12-11欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)