当前位置:数据库 > Oracle >>

oracle SQL语句取本周本月本年的数据

oracle SQL语句取本周本月本年的数据
 
[sql] 
--国内从周一到周日 国外是周日到周六  
select to_char(sysdate-1,'D') from dual;--取国内的星期几 去掉减一取国外的星期--  

 

[sql] 
--取本周时间内的数据  
select * from table  where DTIME >=trunc(next_day(sysdate-8,1)+1) and DTIME<=trunc(next_day(sysdate-8,1)+7)+1 ;  
  
select * from table  where DTIME >=trunc(next_day(sysdate-8,1)) and DTIME<=trunc(next_day(sysdate-8,1)+7);--国外的  
    
select * from table  where  DTIME >=TRUNC(SYSDATE, 'MM')  and DTIME<=last_day(SYSDATE);  
--本月的  
select * from table where to_char(DTIEM,'yyyy')=to_char(sysdate,'yyyy');  
--本年的  

 


Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,