Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

A tricky sql query

577162Mar 19 2009 — edited Mar 24 2009
Hi,

I have data like this....

tab1 table has only one column col1 and it contains near about 3000 rows and all are numeric values.

tab2 has 3 columns col1,col2.col3

I want to generate a sql select statement with every four rows values of tab1 like the following.

Now say in the following example after row value 8 only three rows are there in tab1 then the select statement includes only those three values.

select *from tab1

col1
------
1
2
3
4 select col1,col2 from tab2 where col3 in(1,2,3,4)
5
6
7
8 select col1,col2 from tab2 where col3 in(5,6,7,8)
9
10
11 select col1,col2 from tab2 where col3 in(9,10,11)

I tried it in sql but while doing with case it is will throw error single row subquery returns many rows error.In pl/sql it is possible but how i can achieve it in sql?

Thanks in advance.
This post has been answered by MichaelS on Mar 23 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2009
Added on Mar 19 2009
18 comments
1,144 views