select * from table where int((month(日期字段)-1)/3)+1 = int((month(your_date)-1)/3)+1
解决方案 »
- 问下,关于system登陆以及scott as sysdba登陆的分别?
- 救救我吧!!!!
- 关于零长度字符串的问题
- ORACLE8.16数据库迁移
- 求教!送分了!50分
- 如何知道一个存储过程执行用了多少时间等信息
- 能使oracle9i运行得比较快,一般需要什么pc配置呢?
- 怎样让数据库返回查询只是固定行数,譬如10行
- SELECT TRUNC(TO_DATE('27-OCT-92','DD-MON-YY'), 'YEAR') "New Year" FROM DUAL;返回什么呀?
- sysdate可不可以只存日期,而不存時間?或者有其它的什麼函數只存日期?
- 如何根据远程数据库的sid得到其数据库名?
- 关于一个left join 的问题。
然后,month/3取整 设为n
那个季度就是(n*3+1)到(n*3+3)
再把两个端点日期求的
select * from table_name where date_column between date_end1 and date_end2
怎么回事?难道不能这样用month含数?
AS
TYPE myrctype IS REF CURSOR;
END pkg_test;
/
create procedure get_date(p_date in date,p_rc out pkg_test.myrctype)
as
begin
if to_char(p_date,'q')=1 then
str:='select * from col_date between trunc(p_date,'yyyy') and add_months(trunc(p_date,'yyyy'),3)';
elsif to_char(p_date,'q')=2 then
str:='select * from col_date between add_months(trunc(p_date,'yyyy'),3) and add_months(trunc(p_date,'yyyy'),6)';
elsif to_char(p_date,'q')=3 then
str:='select * from col_date between add_months(trunc(p_date,'yyyy'),6) and add_months(trunc(p_date,'yyyy'),9)';
else
str:='select * from col_date between add_months(trunc(p_date,'yyyy'),9) and (add_months(trunc(p_date,'yyyy'),12)+30)';
end if;
open p_rc for str;
end;
/
beckhambobo(beckham) 贝哥,能否说明一下该程序?