问大家一个问题`!
请问如何根据 年月 条件.判断这个年月是属于上半年or 下半年,然后进行查询.
如:2009 05 ,查出2009 01-2009 06````的所有数据.请问要如何写呢?
select * from dual
where```~~````
请问如何根据 年月 条件.判断这个年月是属于上半年or 下半年,然后进行查询.
如:2009 05 ,查出2009 01-2009 06````的所有数据.请问要如何写呢?
select * from dual
where```~~````
解决方案 »
- 如果将一张表中的10万条数据导入另一张表,需要增量导入,每300条提交一次
- 求答案,谢谢。立马给分。
- 请教各位大侠oracle 9i 可不可以生成awr的报告啊?非常感谢
- 生啦!生啦~~~~快叫喜婆~~~~呵呵~~~~~~~~~~~~~~散分!!!
- 水晶报表问题。。。。急!!!(这儿人多,不好意思,发到这儿来了)
- 关系模式的分解
- 两台ORACLE服务器之间如何编写trigger来调用另一台服务器上的存储过程?
- 出错原因请教
- oracle 9.2.0在solaris安装问题
- ORACLE登陆出现问题,求帮忙!
- apache 遇到 oracle 的问题。
- oracle 11g r2 卸载问题-------!!
where to_char(date1,'mm')<='06'
下半年.....>='06'
PL SQL:IF MONTH(SYSDATE)<7 THEN
select * From tab1 where month(col1) between 1 and 6 and year(col1)=year(sysdate);
ELSE
select * From tab1 where month(col1) between 7 and 12 and year(col1)=year(sysdate);
END IF
SQL> select decode(round((to_char(sysdate,'mm')-6)/6,0),1,'下半年','上半年') from dual;DECODE(ROUND((TO_CHAR(SYSDATE,
------------------------------
下半年SQL>
我的意思是`按照`年、月
如:2009 05 ,查出2009 01-2009 06的所有数据.如:2009 08 ,查出2009 07-2009 12的所有数据 是在where 后面写个判决来实现请问?
--试一下:
select count(*) from your_tableA where to_char(your_date_field,'yyyymm')='200905';
2 connect by rownum<100)
3 select * from tt
4 where date1>=to_date(substr(:inputdate,1,4)||case when substr(:inputdate,5,2)<='06' then '01' else '07' end,'yyyymm')
5 and date1<add_months(to_date(substr(:inputdate,1,4)||case when substr(:inputdate,5,2)<='06' then '06' else '12' end,'yyyymm'),1)
6 ;
where date1>=to_date(substr(:inputdate,1,4)||case when substr(:inputdate,5,2)<='06' then '01' else '07' end,'yyyymm')
and date1<add_months(to_date(substr(:inputdate,1,4)||case when substr(:inputdate,5,2)<='06' then '06' else '12' end,'yyyymm'),1);:inputdate为你要查询的年月
connect by rownum<100)
select * from tt
where date1>=to_date(substr(&inputdate,1,4)||case when substr(&inputdate,5,2)<='06' then '01' else '07' end,'yyyymm')
and date1<add_months(to_date(substr(&inputdate,1,4)||case when substr(&inputdate,5,2)<='06' then '06' else '12' end,'yyyymm'),1)
order by date1
;