select id from (select rownum id from ALL_SOURCE where rownum <= (select end from a)) where rownum > =(select begin from a) ;
08:37:21 SQL> select * from temp; BEGINC ENDC --------- --------- 1 10实际:60 08:37:39 SQL> select id from (select rownum id from all_source where rownum<=( 08:37:50 2 select endc from temp)) where id>=(select beginc from temp); ID --------- 1 2 3 4 5 6 7 8 9 10已选择10行。实际:3104 08:38:05 SQL>
如果我的start和end是两个日期,要按照月份选择,怎么办?
我现在遇见的实际问题就是: start_date end_date text ----------------------------- 2002/1 2002/5 test生成的结果是: text month ------------------------ test 2002/1 test 2002/2 test 2002/3 test 2002/4 test 2002/5请教!
11:19:03 SQL> select * from temp;DT1 DT2 COL3 ---------- ---------- ---------- 01-2月 -03 01-9月 -03 test实际:50 11:20:30 SQL> select add_months(dt1,id-1) from (select rownum id from all_source where rownum<=( 11:20:45 2 select months_between(dt2,dt1)+1 from temp)),temp;ADD_MONTHS ---------- 01-2月 -03 01-3月 -03 01-4月 -03 01-5月 -03 01-6月 -03 01-7月 -03 01-8月 -03 01-9月 -03已选择8行。实际:210 11:20:49 SQL>
--------- ---------
1 10实际:60
08:37:39 SQL> select id from (select rownum id from all_source where rownum<=(
08:37:50 2 select endc from temp)) where id>=(select beginc from temp); ID
---------
1
2
3
4
5
6
7
8
9
10已选择10行。实际:3104
08:38:05 SQL>
start_date end_date text
-----------------------------
2002/1 2002/5 test生成的结果是:
text month
------------------------
test 2002/1
test 2002/2
test 2002/3
test 2002/4
test 2002/5请教!
---------- ---------- ----------
01-2月 -03 01-9月 -03 test实际:50
11:20:30 SQL> select add_months(dt1,id-1) from (select rownum id from all_source where rownum<=(
11:20:45 2 select months_between(dt2,dt1)+1 from temp)),temp;ADD_MONTHS
----------
01-2月 -03
01-3月 -03
01-4月 -03
01-5月 -03
01-6月 -03
01-7月 -03
01-8月 -03
01-9月 -03已选择8行。实际:210
11:20:49 SQL>