Order by date desc in oracle 10g

hil all.
i want to order the query by date desc but i want to retrieve only top 20 records according to date means latest how can i get,
Thanks,

Toon Koppelaars wrote:
But of course you can use analytics too, which other posters will show you.Why not ;-)
Depending on what OP want (Note that these does not return the same thing)
SQL> select empno, ename, hiredate, rnk
  from (select emp.*, row_number() over (order by hiredate desc) rnk from emp)
where rnk <= 5
     EMPNO ENAME      HIREDATE        RNK
      7698 BLAKE                        1
      7876 ADAMS      83-01-12          2
      7788 SCOTT      82-12-09          3
      7934 MILLER     82-01-23          4
      7900 JAMES      81-12-03          5
5 rows selected.
SQL> select empno, ename, hiredate, rnk
  from (select emp.*, dense_rank() over (order by hiredate desc) rnk from emp)
where rnk <= 5
     EMPNO ENAME      HIREDATE        RNK
      7698 BLAKE                        1
      7876 ADAMS      83-01-12          2
      7788 SCOTT      82-12-09          3
      7934 MILLER     82-01-23          4
      7900 JAMES      81-12-03          5
      7902 FORD       81-12-03          5
6 rows selected.Regards
Peter

Similar Messages

  • How we create new data base in oracle 10g express edition

    hello every body.. i student of B tech n new user of oracle so please help me how we creat new data base in oracle 10g express edition

    Hello, Oracle XE can not create more than one instance, the other editions yes, but like other editions XE allows you to create database schemas, schemas logically grouped objects like tables, views, indexes created by a user. By creating an Oracle user is associated with a schema of the same name.
    Using SYS or system accounts for creating user accounts.
    Syntax to create a user:
    create user Your_user
    IDENTIFIED BY password
    default tablespace users;
    grant connect, resources to your_user;
    Edited by: rober584812 on Jun 25, 2010 9:03 PM

  • Date format in Oracle 10g XE

    I'm using Oracle 10g XE on Windows Vista and I'm curious as to what determines the date format.
    According to the globalization section in the Oracle installation guide the NLS_DATE format is dependent on the NLS_LANGUAGE setting. In my database the NLS_LANGUAGE is American, the NLS_TERITORY is America and all other NLS_* parameters are blank (default).
    From that I would expect the default date format to be mon-dd-yyyy.
    However when I run SELECT sysdate FROM dual the date is reported as dd/mm/yyyy and this was the default format when I used SQL Developer and when I used the command line SQL*Plus. Obviously something else is determining the date format, but what?

    Your settings are dependent on NLS_LANG on the client.
    They are derived from (assuming Windows) the regional settings of the O/S.
    This means in Western Europe the default 'American_America.WE8MSWIN1252'.
    This makes the default NLS_DATE_FORMAT dd-mm-yy.
    You can override this in the registry, or set up an after logon trigger.
    Sybrand Bakker
    Senior Oracle DBA

  • Looking for a Web Interface for Editing Data in an Oracle 10g Database

    Greetings all!
    My organization is implementing Oracle 10g Release 2 Enterprise version. We have an employee who will need to edit data in the database which will hold staff phone numbers, email addresses, and other contact information. This employee will never need to administer the database or develop tables, queries, etc. They will only need to add and remove rows of data and edit text values stored in a database table.
    Does Oracle 10g have a built-in, browser-based tool that can be used to edit data in a table via a friendly user interface? If no, can you please recommend an easy to use tool for editing data in an Oracle database?
    Thanks for any help you can provide!
    Rachel

    Justin,
    Thanks very much for the tip!
    Do you know if Oracle 10g has any kind of built-in tool for editing data? I have heard of "The Vault", but that appears to be a tool for administering database users, reports, etc. I am looking for some kind of tool that shows the data in a grid layout (like Microsoft Excel) and allows someone to edit and save data in that grid. A web-based tool would be best, but a desktop tool (especially if it's already part of Oracle 10g) would also be good.
    Thanks again,
    Rachel

  • Migrate existing data base to oracle 10g and cluster it

    hi
    we are currently using sql server 2000 and due to some servere dead locks in the application and due to some load issues we wanted to migrate it to oracle 10g.
    At the same time we wanted to have clustered environment in the same server
    That is windows server.
    Can any one suggest how migration can be done..easily ie..by oracle migration work bench or what...
    At the same time can any one suggest how to cluster data base in windows server
    Thanks
    vkumar

    This is re-engineering from one database platform to another.
    You will have to take into consideration several aspects of your application, from SQL comptability to the application performance (SQL) in the Oracle environment.
    There is no magic to this puzzle, the amount of task involved in moving from one database to another depends on complixity of the application and how many database operations will have to be changed. I would suggest /recommend that you should start with a POC on a specific module /area (probably the most complex) of your application and this should give you some idea in the efforts of doing so.

  • Oracle Data Provider for Oracle 10g

    We have an application certified on the ODP 9.2.0.2102, Oracle Client and Oracle ODBC 9.2.0.6. We have a client who is moving to Oracle 10g client within the next few months but will still be hitting an Oracle 9.2 backend.
    My question is: Is the 9.2.0.2102 ODP compatible with the 10g client, or do we need to certify against a newer version of the ODP? And if the latter, what version of ODP is recommended?
    We plan to certify against the latest of both this year, but for now, we need the path of least resistence.
    Thanks for your help.
    Todd

    It is not "hard" to create your own geocoding schema though you will need to know how to create tables (with Oracle Spatial columns) in Oracle and before you do create the tables you should read through the documentation to be certain you have all of the required data and metadata.
    Navteq, a data provider, also has sample geocoding data (http://www.oracle.com/technology/products/spatial/htdocs/spatial_partners_data.html) as well as data for sale. Downloading and importing the Navteq data might give you a good idea about what you will need to do if you were to build your own geocoding schema using your data.
    I hope this helps.
    -Justin

  • Gis data uploading in oracle 10g database

    hello everybody ,
    i am new to oracle 10g ,but i am working in gis field for sometime now.i wanted to know whether there is any method present to upload a gis (shape file)data,and the erdas imagine data, in oracle spatial without going to buy the hefty ,arc sde license.
    thanks in adavance,
    vipul soni

    They are permitted.
    Pproperly designed 'cartridges' use the published Oracle spec. If they live within the restrictions of XE (size, CPU, and no Java stored procedures) they should work.
    Oracle Locator is an example of a properly designed cartridge. So is intermedia.
    Locator does not have any Java SPs and works in XE.
    intermedia does use Java SPs and does not work in XE.

  • How to maintain Data availability in Oracle 10g RAC when LOADING the data?

    Hi
    we are having Oracle 10g server on Sun Solaris(64 bit) with 8 GB RAM.
    We are in need of moving the database to "Oracle 10g RAC". (Real Application Clusters)
    Our doubt is when loading the data into RAC server, will it affect the application?
    coz' we heared that RAC server should be down when we load the data.
    Is this correct?
    If yes, then How to maintain High data availability when we load the data in RAC server?? Please help me.
    Thanks.

    First, is this the same question that a colleague of yours posted in this thread?
    Data Load in RAC
    Second, are other sessions querying the table that you're loading data into? If so, how are you loading the data?
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Four GB of user data Limitation in Oracle 10g XE

    Hi Mates!
    There is one limitation in oracle XE which is:
    It stores up to four GB of user data.
    I am planning to migrate my database from Oracle 9i to Oracle 10g XE. My queries are below:
    1. Is it possible to migrate from Oracle 9i to Oracle 10g XE?
    2. I am confused regarding Four GB of user data Limitation. I don't understand nothing much about this. Presently If I prepare a dump (export) file in oracle 9i the size becomes around 250MB. If I switch to oracle 10g XE, how long will I be able to use my database?
    Rgds,
    Luther

    Hi Mates!
    There is one limitation in oracle XE which is:
    It stores up to four GB of user data.
    I am planning to migrate my database from Oracle 9i
    to Oracle 10g XE. My queries are below:
    1. Is it possible to migrate from Oracle 9i to Oracle
    10g XE?this is a simple test case, you can install XE, export from 9i and import to XE. I did it before, it worked for me, but this does not mean it will for you, testing is only way to be sure.
    There are lots of limitation of XE mentioned in the Licensing Information Guide.
    http://www.oracle.com/pls/xe102/homepage?remark=tahiti
    2. I am confused regarding Four GB of user data
    Limitation. I don't understand nothing much about
    this. Presently If I prepare a dump (export) file in
    oracle 9i the size becomes around 250MB. If I switch
    to oracle 10g XE, how long will I be able to use my
    database?My XE is ~3,3 GB total, datafile + tempfile size, apex applications are working without problem. But consider all syatem + user data as a total, so 250 MB user data won't be a problem, most probably.
    Rgds,
    Luther

  • Data Cartridges in Oracle 10g XE

    Has anybody ever used Oracle 10g Express Edition and installed a third party data cartridge?
    Just wondered if they worked OK and were allowed under the licence agreement. I haven't read anywhere in the licence that they are forbidden and I wondered if it was possible to install them.
    Many thanks.

    They are permitted.
    Pproperly designed 'cartridges' use the published Oracle spec. If they live within the restrictions of XE (size, CPU, and no Java stored procedures) they should work.
    Oracle Locator is an example of a properly designed cartridge. So is intermedia.
    Locator does not have any Java SPs and works in XE.
    intermedia does use Java SPs and does not work in XE.

  • Data moving between Oracle 10g with CLOB fields

    Hi all,
    I have a trouble in migrate data between Oracle 10g with different platform. The worst thing is that I don't have a DBA account for the DB importing data. I think I can't use IMP or IMPDP in this way. So I seek help from sql developer, but it seems having another problem with CLOB data moving.
    Re: EA2 : SQL Developer 1.5 : export data CLOB columns
    in the thread, I found someone wrote this:
    - SQL Developer v1.5 EA2 - exports first 4000 chars (which is anyway too small for me, because my CLOBs are larger - if they were smaller, I would have made them VARCHAR2s instead!).
    I would like to ask:
    1, What SQL Developer v1.5 EA2 is? Is it the Data Modeling one?
    2, How to export table data with CLOB with SQL Developer v1.5 EA2? Since 4000 chars is enough for me to use.
    OR any other method to export CLOB but not IMP / IMPDP ?
    Now I am using the spool of sqlplus to export CLOB.
    Many thanks,

    1. The EAs are Early Adapters, betas, so you should expect the same behaviour from the latest 1.5.4 production release.
    2. Exports can be done with the Database Export tool, through the table's context menu in the navigator tree or the result grid's context menu.
    Have fun,
    K.

  • Create data dump in Oracle 10g

    Hi All,
    Can somebody please tell me how to create a data dump and then import the database structure and data from an existing database?
    The data dump would consist of the complete database structure, i suppose.
    I am using Oracle 10g Rel 1.
    Thanks in Advance,
    Tanuja

    Note, neither classical export nor datapump is really a database backup. You only perform a logical data extraction,but it's difficult to recreate a lost database based only on export dumps. Additionally you will have loss of data,because you only can restore the data as it was,when you did the export. Changes made later are lost. See export/import as an add-on,but backup your database physically. The best way to do this is (in my opinion) RMAN.
    http://download.oracle.com/docs/cd/B19306_01/backup.102/b14193/toc.htm
    Werner

  • Data source from Oracle 10g problem

    Dear Sir,
    We met a problem when we moved on Oracle 10g from Oracle 9i in the loading process. The scenario is that SQL Server as Data Warehouse, SSIS as ETL tool. But the length of string column as data source table in SSIS grows up 4 times when using Oracle 10g. For example, ABC table x varchar2(8) --> x varchar(32) -->x varchar(8) --> x varchar(8) {Oracle 10g        SSIS(source) }
    This doesn’t influence the loaded result (I did not find any problem until now), but that influence loading performance and we worry about potential problems.
    Do you have any idea or have you met the same problem before? Is I need setup some parameters like "code page"
    Thanks,
    Jacob

    You could try General Database Discussions the main db foum.
    What are you using to migrate your database? Why is it being mapped from varchar2(8) to varchar2(32). It sounds like someone/something is intervening here.
    Barry

  • How to import a data base into oracle 10g.

    hi all
    when am using the scott/tiger username and password in the SQL plus i got this msg..
    "the account is locked"
    how can i solve this issue?
    and when i use the same username and password scott/tiger in addition to define a Host string " orcl" which is my new automatically generated database while installation.. it gives me this msg: TNS: no listener.
    any help ?
    by the way i succeed to login using .. system/zaq123 which is my own created password while installing oracle 10g ....ver 10.1.2.0 ..... in addition to the Host string "orcl" ......

    If you're not familiar with OEM, or you want to learn, you can unlock that account from SQL*Plus, too.
    And when you unlocked SCOTT, don't forget to look after your TNSNAMES and LISTENER configuration...
    Good luck!

  • How to display result order by date desc?

    Hi Everyone,
    My DB version is
    BANNER                                                        
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production                          
    CORE 10.2.0.1.0 Production                                        
    TNS for Linux: Version 10.2.0.1.0 - Production                  
    NLSRTL Version 10.2.0.1.0 - Production                          
    Please do have a look at this query and the result displayed. It's always showing results in draw_dt asc. I need to get this result as draw_dt desc. Please suggest something.
    select rownum as sl_no,
           sub.patient_name,
           sub.external_id,
           sub.modality,
           sub.account_number,
           sub.hlab_num,
           sub.spectra_mrn,
           sub.draw_dt,
           sub.requisition_number,
           sub.facility_name,
           sub.facility_id,
           sub.corporation_name,
           sub.acronym,
           sub.patient_id,
           SUB.TEST_ID,
           count(sub.requisition_number) over (partition by null) as entity_count
    from(
    select distinct
            (select p.last_name || ', ' || p.first_name
              from patient p
             where p.patient_id = loc.patient_id) as patient_name,
           (select p.external_id
              from patient p
             where p.patient_id = loc.patient_id) as external_id,
           (select p.spectra_mrn
            from patient p
            where p.patient_id = loc.patient_id) as spectra_mrn,
           ord.requisition_number as requisition_number,
           f.facility_name as facility_name,
           f.facility_id as facility_id,
           (select fad.account_type as modality
              from patient p,
                   patient_facility_modality pfm,
                   facility_account_modality fam,
                   facility_account_detail fad
             where p.patient_id = pfm.patient_id
               and pfm.facility_account_modality_id =
                                                  fam.facility_account_modality_id
               and fam.facility_account_detail_id = fad.facility_account_detail_id
               and p.patient_id = loc.patient_id
               and pfm.facility_id = loc.facility_id) as modality,
           (select fad.account_number as account_number
              from patient p,
                   patient_facility_modality pfm,
                   facility_account_modality fam,
                   facility_account_detail fad
             where p.patient_id = pfm.patient_id
               and pfm.facility_account_modality_id =
                                                  fam.facility_account_modality_id
               and fam.facility_account_detail_id = fad.facility_account_detail_id
               and p.patient_id = loc.patient_id
               and pfm.facility_id = loc.facility_id) as account_number,
           (select fad.hlab_num as hlab_num
              from patient p,
                   patient_facility_modality pfm,
                   facility_account_modality fam,
                   facility_account_detail fad
             where p.patient_id = pfm.patient_id
               and pfm.facility_account_modality_id =
                                                  fam.facility_account_modality_id
               and fam.facility_account_detail_id = fad.facility_account_detail_id
               and p.patient_id = loc.patient_id
               and pfm.facility_id = loc.facility_id) as hlab_num,
           loc.order_draw_dt as draw_dt,
           c.corporation_name as corporation_name,
           c.corporation_acronym as acronym,
           loc.patient_id,
           loct.test_id
      from lab_order_occ loc,
           lab_order_occ_test loct,
           facility f,
           corporation c,
           order_requisition_header ord
    where loc.lab_order_occ_id = loct.lab_order_occ_id
       and loc.facility_id = f.facility_id
       and f.corporation_id = c.corporation_id
       and ord.patient_id = loc.patient_id
       and ord.facility_id = loc.facility_id
       and ord.draw_dt = loc.order_draw_dt
       and loc.order_draw_dt between sysdate - 65 and sysdate
       and loc.status = 'A'
       and loc.msg_sent_to_lab_yn = 'Y'
       and loct.test_id in (
                       select test_id
                         from test_required
                        where required_test_code in (
                                                     select test_code
                                                       from interface_adt_aoe_master))
       and upper (c.corporation_acronym) in ('CORVA', 'DSI', 'USRC', 'DLYSNEWCO')
       and not exists (
                        select 1 from emr_adtaoe_dtl
                        where patient_id = loc.patient_id
                        and facility_id = loc.facility_id
                        and status = 'Y'
                        ))sub
    ORDER BY
            sub.draw_dt,
    --         sl_no,
             sub.corporation_name,
             sub.facility_name,
             SUB.PATIENT_NAME
             desc;
    Result
    SL_NO
    PATIENT_NAME
    EXTERNAL_ID
    MODALITY
    ACCOUNT_NUMBER
    HLAB_NUM
    SPECTRA_MRN
    DRAW_DT
    REQUISITION_NUMBER
    FACILITY_NAME
    FACILITY_ID
    CORPORATION_NAME
    ACRONYM
    PATIENT_ID
    TEST_ID
    ENTITY_COUNT
    9
    New, Pat
    123456
    HEMO
    72910
    A102805
    366999
    29-DEC-13
    9KT005A
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    2
    New, Pat
    123457
    HEMO
    72910
    A102805
    366999
    29-DEC-13
    9KT0057
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    7
    New, Pat
    123458
    HEMO
    72910
    A102805
    366999
    29-DEC-13
    9KT0059
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    16
    Erere, Gggg
    123459
    HEMO
    72910
    A102805
    622200
    29-DEC-13
    9KT0058
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    622
    5558
    16
    10
    Erere, Gggg
    123460
    HEMO
    72910
    A102805
    622200
    29-DEC-13
    9KT0056
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    622
    5558
    16
    1
    Test, Pat
    123461
    HEMO
    72910
    A102805
    367021
    30-DEC-13
    9KT0065
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    14
    Test, Pat
    123462
    HEMO
    72910
    A102805
    367021
    30-DEC-13
    9KT0064
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    4
    New, Pat
    123463
    HEMO
    72910
    A102805
    366999
    30-DEC-13
    9KT005W
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    3
    New, Pat
    123464
    HEMO
    72910
    A102805
    366999
    30-DEC-13
    9KT005X
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    8
    New, Pat
    123465
    HEMO
    72910
    A102805
    366999
    30-DEC-13
    9KT005V
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    13
    Test, Pat
    123466
    HEMO
    72910
    A102805
    367021
    01-JAN-14
    9KT006J
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    5
    Test, Pat
    123467
    HEMO
    72910
    A102805
    367021
    01-JAN-14
    9KT006G
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    6
    Test, Pat
    123468
    HEMO
    72910
    A102805
    367021
    01-JAN-14
    9KT006H
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    11
    Test, Pat
    123469
    HEMO
    72910
    A102805
    367021
    05-JAN-14
    9KT0077
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    15
    Test, Pat
    123470
    HEMO
    72910
    A102805
    367021
    05-JAN-14
    9KT0076
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6203
    5558
    16
    12
    New, Pat
    123471
    HEMO
    72910
    A102805
    366999
    06-JAN-14
    9KT0075
    DCI Freehold
    90
    DIALYSIS CLINIC, INC.
    DLYSNEWCO
    6181
    5558
    16
    See the date value for draw_dt column. It's always in asc order. How can I display this result set with draw_dt desc order? Please suggest something.

    ORDER BY  
            sub.draw_dt desc, 
    --         sl_no, 
             sub.corporation_name, 
             sub.facility_name, 
             SUB.PATIENT_NAME 
             desc;

Maybe you are looking for

  • I have a Windows 7 Desktop and home sharing won't work to my Windows 8 laptop?

    My Windows 7 computer is recongnizing my laptop for home sharing, but my Windows 8 laptop won't recognize the home sharing with the desktop. Both computers are authorized and home sharing is on. HELP! I followed the process on the "How to move your m

  • Download in adf 11

    I'm using fileDownloadActionListener component attached to a button code jsp: <af:fileDownloadActionListener method="#{Dok.onDownload}" contentType="#{Dok.mime}" filename="#{Dok.fname}"/> backing bean: public void onDownload(FacesContext facesContext

  • Paging large results?? - Woodstock + Provider Framework

    I'm using the Table & TableRowGroup components out of the com.sun.webui.jsf.component package. I created a table backed by an ObjectListDataProvider. Since my query will literally return thousands of very large objects, I must implment the provider i

  • Why does Discoverer put my custom function into GROUP BY

    To make things clear with simple example: I have 10 id's from people (people.id) and sum function on their salary [sum(people.salary)] during a period of time that i set in my parameters. The sql looks something like this: SELECT PEOPLE.ID ,SUM(PEOPL

  • Is there an instagram app for macbooks?

    I do not have an iphone, but I do have a macbook. I'd like to use the same filters that the instagram iphone app has with my photos stored in iphoto. Any suggestions?