I need to create a table from another table but I only want the last 10000 records to be added in the new table. Can any one tell me how this can be done by modifying this statement:
create table export_cluster_125m
as
(select * from cluster_125m);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You say you want the “last” 10000 rows. Assuming this can be determined by a column such as
created_dateyou would need to order by that column (descending) and then take the first 10000 rows returned by that query. This can be done using ROWNUM, but not like this:That will return some 10000 rows, ordered by created_date (descending) – but they will not generally be the latest 10000 rows. To do that you need to nest the query like this:
Now all rows are sorted in descending order, and then the first 10000 are taken.