這個就可以查出你web_date中指定某年某月第一天、最後一天的資料了:
但如果你的欄位year_month是date型別的,就這樣寫:
select * from web_date a where a.year_month in
(select to_date("201502"||"01","yyyymmdd") from dual
union all(select to_date(to_char(last_day(to_date("201502", "yyyymm")),"yyyymmdd"),"yyyymmdd")from dual));
但如果你的欄位year_month是char型別的,就這樣寫:
( select "201502"||"01" from dual
union all( select to_char(last_day(to_date("201502", "yyyymm")),"yyyymmdd")from dual));
"201502"這個是變數,你可以任意更改。
這個就可以查出你web_date中指定某年某月第一天、最後一天的資料了:
但如果你的欄位year_month是date型別的,就這樣寫:
select * from web_date a where a.year_month in
(select to_date("201502"||"01","yyyymmdd") from dual
union all(select to_date(to_char(last_day(to_date("201502", "yyyymm")),"yyyymmdd"),"yyyymmdd")from dual));
但如果你的欄位year_month是char型別的,就這樣寫:
select * from web_date a where a.year_month in
( select "201502"||"01" from dual
union all( select to_char(last_day(to_date("201502", "yyyymm")),"yyyymmdd")from dual));
"201502"這個是變數,你可以任意更改。