INSERT using ROWNUM [message #325974] |
Mon, 09 June 2008 14:47  |
myqueries
Messages: 5 Registered: June 2008
|
Junior Member |
|
|
Hi All,
It would be appreciate if you can respond to my query asap.
I have 2 tables. one is base table and one is staging table.
I am selecting some of the columns from base table minus some of the columns from staging table and inserting those result columns into staging table.
I want to insert only 50 rows using ROWNUM. can anybody guide me how to tune this below query with ROUNUM<=50.
inset into table_stg(
column1,
columun2,
column3,
--,
--)
select
column1,
columun2,
column3,
---,
--
from basetable
where country='US'
MINUS
select
column1,
columun2,
column3,
--,
--
from table_stg
Thanks in advance.
MK
|
|
|
|
|
|
|
|
|
Re: INSERT using ROWNUM [message #325988 is a reply to message #325974] |
Mon, 09 June 2008 15:32   |
myqueries
Messages: 5 Registered: June 2008
|
Junior Member |
|
|
Thanks for your reply Joy,
The problem is I can not do the select * from as the table has some restrictions to see all columns. I want to insert those selected columns in stg table using ROWNUM.
Please suggest me where can I use this ROWNUM in my insert statment which I mentioned.
Really appreciate your help.
Thanks,
MK
|
|
|
|
|
|
Re: INSERT using ROWNUM [message #326142 is a reply to message #325992] |
Tue, 10 June 2008 05:28  |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
If you've done someting like:select
column1,
columun2,
column3,
---,
--
from basetable
where country='US'
and rownum <=50
MINUS
select
column1,
columun2,
column3,
--,
--
from table_stg
then this won't give you 50 rows as output.
It will take the first 50 rows (at random, as there's no Order by) and then remove from this set of 50 any rows match rows returned by the second half of the query.
|
|
|