Trying to get the top N records from a query.
Hello,
Im trying to get the top N records of a random query. I've been looking for a decent solution for a while now and the 2 solutions I've come across are:
select *
from (select * from qrs_klantgroepen order by code) a
where rownum < 10
ORA-00907: missing right parenthesis
The query works when I remove the order clause from the subquery, but it's mandatory to get the results I need.
The next solution:
select *
from (select code, row_number() over (order by code) from qrs_klantgroepen) a
where rownum < 10
ORA-00923: FROM keyword not found where expected
Apparently the construct used here isn't supported by my oracle version.
I'm using oracle Oracle8 Enterprise Edition Release 8.0.5.2.1.
Is there another way I can achieve the results I want?
Looking forward to your replies.
Frederik
it must be nostalgy, but I would try something like
SQL> select * from emp e where 5>(select count(*) from emp where ename<e.ename) order by ename;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 1987-05-23_00:00:00 1100 20
7499 ALLEN SALESMAN 7698 1981-02-20_00:00:00 1600 300 30
7698 BLAKE MANAGER 7839 1981-05-01_00:00:00 2850 30
7782 CLARK MANAGER 7839 1981-06-09_00:00:00 2450 10
7902 FORD ANALYST 7566 1981-12-03_00:00:00 3000 20
SQL> select * from (select * from emp order by ename) where rownum<6;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7876 ADAMS CLERK 7788 1987-05-23_00:00:00 1100 20
7499 ALLEN SALESMAN 7698 1981-02-20_00:00:00 1600 300 30
7698 BLAKE MANAGER 7839 1981-05-01_00:00:00 2850 30
7782 CLARK MANAGER 7839 1981-06-09_00:00:00 2450 10
7902 FORD ANALYST 7566 1981-12-03_00:00:00 3000 20Message was edited by:
Laurent Schneider
Similar Messages
-
Getting the top 10 issues using a query
Version 11g, Apex 4.1
Hi There,
I have a table with the following structure
error_code date error_type
e1 10-jun-2012 P
e1 10-jun-2012 P
e2 10-jun-2012 C
e3 09-jun-2012 P
e4 09-jun-2012 D
e20 01-jan-2011 cI have to get the top 10 errors along with the counts.
I know how to get the counts, I was not sure how to restrict it to the top 10 of the whole list
Thanks,
Sun
Edited by: sun1977 on Jun 12, 2012 6:13 AMselect *
from (select error_code,count(error_code) arc from err_log group by error_code order by arc desc) where rownum < 11 ; The order by in the subquery does not garantie, that the result is ordered outside. Therefore rownum not necessarily works as expected.
But of course your questions how the top 10 are defined are important to give the correct answer.
Regards
Marcus -
How to get the last inserted record from a table ?
:-) Hiee E'body
I work on Oracle 8i and need to get the last
record inserted in a table.
I have tried using rownum and rowid pseudo-columns
but that doesn't work.
Can you please help me out ?
:-) Have a nice time
Vivek Kapoor.
IT, Atul Ltd.,
India.I'm not sure about 8i features.
I assume here that you don't have 'Date-Time' stamp columns on the table which is the easiest way to determine the last inserted row in the table.
If not try the following :-
select address, piece, SQL_TEXT
from V$SQLTEXT
where upper(sql_text) like '%INSERT INTO TABLE_NAME%'
Substiute the TABLE_NAME with the name of the actual table.
Have fun.
Regards,
Shailender
:-) Hiee E'body
I work on Oracle 8i and need to get the last
record inserted in a table.
I have tried using rownum and rowid pseudo-columns
but that doesn't work.
Can you please help me out ?
:-) Have a nice time
Vivek Kapoor.
IT, Atul Ltd.,
India. -
I need help trying to get the ipad i bought from someone on my act
I bought a ipad from someone now trying to get it on my act
You need to explain what you are trying to do in a little more detail. I'm guessing that you want to activate the device but you can't because the person that you bought it from didn't erase it properly. You will need their help for this. They have to follow the instructions in this kb article before you can use the device.
What to do before selling or giving away your iPhone, iPad, or iPod touch - Apple Support
They must do this for you. Nobody here can help with it other than the person that you bought it from. If you are asking about something else, you really do need to be more specific. -
Getting the un updated records from receiver JDBC
Hi Friends,
I am doing the Proxy - jdbc integration. Consider my proxy sends 10 records to JDBC to update. Consider bcoz of some reason the jdbc updates only 8 records i need to get the 2 records back to Proxy which is not updated in the DB.
Should i need to use the Proxy and JDBC channel as syn or seperate integration should be built. I have seen some documents, that we can get the count of the updated records from jdbc receiver, but i dont need the count i need the record which is not been updated.
How can i do it. please give ur inputs.
thanks
PremUnless you are using SP on JDBC side and explicitly build a record set to send back the data it might not be possible. I am not sure if a custom record set could be returned in JDBC sync receive adapter. You can realize this by updating some other table on JDBC side and then polling that table to update ecc back.
VJ -
To get the number of record from cmp
how can i get the specific number of record (25 records) from cmp using weblogic8?
anybody know pls tell.http://java.sun.com/j2se/1.4.1/docs/api/java/io/File.html
-
What is the best way to get the end of record from internal table?
Hi,
what is the best way to get the latest year and month ?
the end of record(KD00011001H 1110 2007 11)
Not KE00012002H, KA00012003H
any function for MBEWH table ?
MATNR BWKEY LFGJA LFMON
========================================
KE00012002H 1210 2005 12
KE00012002H 1210 2006 12
KA00012003H 1000 2006 12
KD00011001H 1110 2005 12
KD00011001H 1110 2006 12
KD00011001H 1110 2007 05
KD00011001H 1110 2007 08
KD00011001H 1110 2007 09
KD00011001H 1110 2007 10
KD00011001H 1110 2007 11
thank you
dennis
Edited by: ogawa Dennis on Jan 2, 2008 1:28 AM
Edited by: ogawa Dennis on Jan 2, 2008 1:33 AMHi dennis,
you can try this:
Sort <your internal_table MBEWH> BY lfgja DESCENDING lfmon DESCENDING.
Thanks
William Wilstroth -
How to get large no of records from adf table
Hi All,
I'm working on adf.I'm using jdeveloper 11.1.1.5 version.In my adf application i have 1000 records in my adf table.I want to get the 500 selected records from that table at a time.But im not able to get huge number of records.How can i get the records from adf table.Please give me ur valuable suggestions.
Thanks!Hi.
for large record check the oficial doc.
http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvvo.htm#CEGDBJEJ
PAGE_RANGING is the best option for large tables.
and these maybe will help you
Re: Performance scrolling large ADF tables
Re: Expert opinion needed: Best practices to handle huge rowsets on UI -
Whether its possible for calculating Grand total the Top 20 records?how?plz
Hi Experts,
could you please let me know that whether the Grand total can be calculated by selecting the Top 20 records from the table.
please....its urgent......I agree with Christian, we need additional clarification.
If you are looking for a report which shows only the Top 20 records and a Grand Total, here are the steps you follow:
1. From the Criteria tab in Answers, create a filter on the column you wish to show only the top 20 records.
2. Set Operator to - "Is in top"
3. Set Value to - "20"
From there - go to the results tab. Locate the data column you would like to "count" and select the "total by" button. (Looks like an E)
Hope this helps. If you are looking for something else, please provide us with a more detailed explanation.
Thanks. -
Using Pro Logic X to record. I have several tracks and I'm trying to record an audio track. I have the mic connect to Avalon 737 then into apollo interface. When I record all track are being recorded into that track. I can't just get the audio to record.
Thanks for responding. Everything seems to work right except for the when I plug into the 737. Ok let me see if I can be more clear. I had this set up done with two representatives of Neumann, and DBox. Here it is I hope this helps. 32 Channel snake (24 Inputs 8 outputs) Channels 1-8 from snake to my Octopre for Drums. From Octropre output quarter inch lines into the Apollo 2, quarter inch input. This is so that the Apollo 2 is taking the drum tracks. Snake Channel 9-12 into Apollo 1 channels 1-4 xlr. Snake Channel 13-16 into Apollo 2 Channels 1-4 xlr. Snake Channel 17 into the 737, output of 737 into Channel 5 of the Apollo 1 quarter inch.
Ok The Dbox. Sum output L&R into channel input 7&8 of Apollo 1. Apollo 1 output channels 1-8 into summing input channel 1-8 of Dbox. Apollo 1 main L&R going to main analog input L&R of Dbox. Spid out to DAW input of Dbox. I have both ADAT of both Apollos connected by optical wire. Also have port 2 of Apollo 1 into port 1 of Apollo 2 connected by Firewire. Let me know. Hope I got it right. Thanks for responding. -
Ive just got a new iPhone4 and I am trying to get the App's ie games from my iPhone3 onto the 4 and retain the same levels that I have reached on the 3,
The Apps have gone onto the 4 but its making me re-start everything from level 1?
Ive paid $$ for the games and then more $$ within the games via iTunes for in game purchases and desperatly want the games on the 4 with the levels that I have reached on the 3!
Can anyone help!! Please!!!! My Smurfs and Animals are starving HahahahaMate, it's good to hear that you have gotten the iPhone 4 but sorry to burst your bubbles. Not all games can have the "saved" data ported over.
Normally when you save a game in iPhone, the memory used is in the flash memory of the device. Those that can be ported over, reason is due to the data being saved over the air and when you logged in on a new device, it recognises you via the userID.
Maybe you can try to backup your iPhone 3, and restore the file onto your iPhone 4. Not too sure if that would brick your phone though. -
HT201328 I am trying to get the unlock code from ATT
I am trying to get the unlock code from ATT for my Iphone 4S bought in an Apple store, and now they refused to give it, because it is reported as stolen.
I have all the invoices and recepts, .
How can I do to unlock the phone if they continue in their negative and hostile attitude???
Thanks,
Paul
[email protected]hipichik Hello there. Let's get more specific information. What type of lock code are you referring to? And what are you looking to do with your phone?
SheritaH_VZW
Follow us on Twitter
@VZWSupport -
i have been trying to get my ibook g4 fixed from apple for 6 years now. my ram doesnt work and the logic board is f'd up aswell... i know 12 people that have had the same issue. 4 of them got there ibooks replaced. anyone know what to do? all 4 ibooks were replaced outside warranty, why wont apple help me...
Apple supports most of their computer products for a 7 year period, could be that your IBook is well past any kind of help.Secondly parts are no longer being made for this machine and never will be again. Finally I find it hard to believe that nothing has been done with this for 6 years.Have you documented the reasons why you were turned down for repairs ? were the replaced Ibooks within a couple of months of warranty expiration? What model is your IBook ? At least if we knew what the model #, some of the more techy types could find out if there were any repair programs for your model.
Seems odd that you'd hang on to a non-working IBook for that long. -
How to get the TOP MAT from a component material of BOM list?
I only kown a sub material of a BOM Llist & not sure its level in the TOP MAT's BOM.
How can i get the TOP MAT of this sub material?
Any BAPI or Function?
TKS a million~~~HI .. in my view you should ask your ABAP to help you with a small program to solve your purpose, i am not aware of any system available t-code/ program ..... hence this is what we also did at client place.
-
Different ways to get the last 5 records ordered by date
I have a query no that returns the tickets ordered by moddt, modification date,
I was thinking of adding a select on top, to get the last 5 records of that list the select already generates. An other way was to use that select to create a view,
and get the 5 last records that way. I also though of a possibly impossible cursor with a sequence, but hmm well I consider that not a good solution.
So I'm trying to find a way, using a select, the topmost select which is not completed yet, to get the last 5 records. Maybe I should just try the rownumber thing again or something likewise.
Select * from(
select * from(
Select ticketid, appliecatiecd, categorieid, substr(titel,&,200)||' ...' "titel", klantproriteitid, interneprioriteitid,
(select g.voornaam||' '||g.naam
from gebruiker g
Where g.gebruikerid = t.gebruikerid
And t.applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd))"aangemaakt door",
(select s.statusdefoms "status"
From status s
Where s.statusid = t.statusid
And t.applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd)) "status",
Versieid,
Moddt,
Row_number() over (order by ticketid desc) rn
From ticket t
Where applicatiecd = NVL(:P0_applicatiecd, :F101_applicatiecd) )
Order by moddt)
Where --Hi Floris,
You can also use RANK: http://www.dba-oracle.com/oracle_news/oracle_faq/faq_beg_sql_top_n_rows.htm
Regards Pete
Maybe you are looking for
-
Photoshop CC 2014, "Could not complete your request b/c program error"
I've not seen this since the early CS days, and generally found Photoshop CC to be extremely stable. However since starting to use CC 2014, I've had this happen six times - not in a row, just at random occasions doing completely unrelated things. Exa
-
Error in IE while starting PC-UI
Hi all, I get the error "<b>Bad Gateway The following error occurred: [code=DNS_HOST_NOT_FOUND] The host name was not found during the DNS lookup. Contact your system administrator if the problem is not found by retrying the URL.</b>" while trying t
-
Reverse document for check voided with FCH9
I voided a manual check that was created by using FCH9. I want to be able to reverse the document, but when I tried to reverse, I got an error that the document was already cleared and could not be reversed. Is there a way to reverse the payment docu
-
Hello, We are currently experiencing some weird behaviour in Outlook 2013 since we added Shared Mailboxes. When we run Outlook 2013 with cached mode enabled: - I create a new e-mail and send it. - The e-mail goes to the outbox, and get's 'send'. - No
-
How to pack and send the iMac 21.5 2013?
Hi, the shipping company is asking me about the width (inch), height, length and weight (lbs) of the original box of the iMac 21.5 ME087 late 2013, I want to buy in US. Someone can help me?