Why this query gives me wrong

Hello

My java file, I get the data in this format 18-11-2010 0:00:00

So I used the query in this way

select distinct to_char (USAGEDATE, ' yyyy-mm-dd hh: mm :) from testsummary where USAGEDATE BETWEEN 2010-10-18 0:00:00 and 18-11-2010 0:00:00)


Help, please

query is incorrect and needs to read

Select distinct to_char (USAGEDATE, 'yyyy-mm-dd hh24:mi:ss')
of testsummary
where USAGEDATE BETWEEN to_date ("2010-10-18 0:00:00 ',' yyyy-mm-dd hh24:mi:ss'") and to_date ('18-11-2010 0:00:00 ',' yyyy-mm-dd hh24:mi:ss')

----------------------
Sybrand Bakker
Senior Oracle DBA

Tags: Database

Similar Questions

  • Why this query can remove duplicates?

    Why this query can remove duplicates? Can someone give me detailed explanation?

    Thank you
    select salary from employees union select salary from employees;

    Hello

    See the docs.

    ' Example of the UNION
    The following statement combines the results of two queries with the UNION operator which eliminates duplicates of selected lines.
    "This statement shows that you must match the data type (using the function TO_CHAR) when the columns do not exist in one or the other table"

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/queries004.htm#i2054381

    Edit

    Here's another interpretation of your question:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:1224636375004

    Published by: hoek on October 22, 2009 17:40

  • Why this code give me duplicate data

    HII, all the
    Why this code give me duplicate data
    SELECT (G.NAME_1 ||' '||G.NAME_2||' '||G.NAME_3||' '||G.NAME_4) AS NAME,
                  R.RES_NUM
    FROM    GUST G , RESERVATION R,ROOM_DETAILS S,ROOMS RR
    WHERE   G.RES_NUM = R.RES_NUM
    AND     R.RES_NUM = S.RES_NUM
    AND     RR.OCCUPIED = 'Y'
    RES_NUM
    --------
    1282
    1282
    1282
    1282
    1280
    1280
    1280
    1280
    1281
    1281
    1281
    1281
    1310
    1310
    1310
    1310
    
    16 rows selected

    Try this:

    SELECT DISTINCT (G.NAME_1 ||' '||G.NAME_2||' '||G.NAME_3||' '||G.NAME_4) AS NAME,
                  R.RES_NUM
    FROM    GUST G , RESERVATION R,ROOM_DETAILS S,ROOMS RR
    WHERE   G.RES_NUM = R.RES_NUM
    AND       R.RES_NUM = S.RES_NUM
    AND       RR.OCCUPIED = 'Y'
    
  • Why this query produces no output?

    Why this query produces no output?
    select * from
    (
    SELECT 40 as startvalue, (24 * 60)*(To_Date('00:40', 'HH24:MI') - To_Date('00:00', 'HH24:MI')) as c
    FROM dual di
    ) q
    where q.c = q.startvalue

    And just to show that it works if round you...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select * from
      2  (
      3  SELECT 40 as startvalue, round((24 * 60)*(To_Date('00:40', 'HH24:MI') - To_Date('00:00', 'HH24:MI')),0) as c
      4  FROM dual di
      5  ) q
      6* where q.c = q.startvalue
    SQL> /
    
    STARTVALUE          C
    ---------- ----------
            40         40
    

    I certainly wouldn't say using TRIM as PS has suggested. TRIM is a string function, not a digital function.

  • This query gives the original sequence that increment of original value and start with original number?

    Thank you!

    Select dbms_metadata.get_ddl ('SEQUENCE', 'COURSE_NO_SEQ') of double;

    Hello

    No it will not give the sequence. This u give query will be, how U created the sequence, I mean how u written code for the design of this sequence. That's all...

    After you generate the query, you can use it in another schema, if the sequence is not available with this same name. After you have compiled successfully in other patterns, this sequence will start to give the starting number sequence number...

    See you soon!

  • Stupid old backpacker (me) cannot understand why this query returns 1 row

    Hi all

    In reference to {: identifier of the thread = 2456973}, why do
    select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
    , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
    from emp group by job;
    only 1 rank and not 1 for each task? In fact, I had to test it myself to believe.

    It returns the data as if the query were
    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)
    Using only a single aggregate (count or sum) returns 1 row per job, as expected

    John Stegeman wrote:
    It returns the data as if the query were

    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
    from emp group by job)
    

    Exactly the point ;-)

    It seems that Oracle actually do, a group of 'double' in the same operation.
    Attend plans to explain in this example:

    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3  from scott.emp group by job;
    
        CLERKS  SALESMANS
    ---------- ----------
             0          0
             0          0
             0          0
             0          4
             4          0
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1697595674
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  HASH GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    

    And compare it to the one with the double aggregates:

    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3  from scott.emp group by job;
    
        CLERKS  SALESMANS
    ---------- ----------
             4          4
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 417468012
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    There are GROUP BY hash and SORT GLOBAL times.

    It is really unnecessary to an aggregate on an aggregate - if two aggregates are used "in the same group level.
    Sum() aggregates are used on an already aggregated value, so it doesn't look like Oracle which actually cures like 'first do the internal aggregate using the group specified by and then do the external aggregation on the result with any group.'

    Look at this example where I combine aggregates "double" with "single" aggregates:

    SQL> select sum(count(decode(job, 'CLERK', 1, null))) CLERKS
      2       , sum(count(decode(job, 'SALESMAN', 1, null))) SALESMANS
      3       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS2
      4       , count(*) COUNTS
      5  from scott.emp group by job;
    
        CLERKS  SALESMANS SALESMANS2     COUNTS
    ---------- ---------- ---------- ----------
             4          4          1          5
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 417468012
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   1 |  SORT AGGREGATE     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   2 |   HASH GROUP BY     |      |     1 |     8 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    When you mix "doubles" and "single" aggregates, Oracle decides that unique aggregates belong to the 'outer' aggregation
    SALESMAN2 did a count on the aggregated work column which is the result of the 'internal' group by - so only 1.
    The count (*) is also the result of the aggregation of the 'internal '.

    I don't know if it's documented or if it is an 'effect' of internal code used for GROUPING SETS or the internal code used to enable the analytical functions like this:

    SQL> select count(decode(job, 'CLERK', 1, null)) CLERKS
      2       , count(decode(job, 'SALESMAN', 1, null)) SALESMANS
      3       , sum(count(decode(job, 'CLERK', 1, null))) over () CLERKS2
      4       , sum(count(decode(job, 'SALESMAN', 1, null))) over () SALESMANS2
      5  from scott.emp group by job;
    
        CLERKS  SALESMANS    CLERKS2 SALESMANS2
    ---------- ---------- ---------- ----------
             0          0          4          4
             4          0          4          4
             0          0          4          4
             0          0          4          4
             0          4          4          4
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 4115955660
    
    ----------------------------------------------------------------------------
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------
    |   0 | SELECT STATEMENT    |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   1 |  WINDOW BUFFER      |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   2 |   SORT GROUP BY     |      |     5 |    40 |     4  (25)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   112 |     3   (0)| 00:00:01 |
    ----------------------------------------------------------------------------
    

    Personally, I think that I would have preferred if Oracle has raised an error on this "double aggregation" and therefore require me to write this way (if it's the result I wanted):

    select sum(CLERKS), sum(SALESMANS)
    from (select count(decode(job, 'CLERK', 1, null)) CLERKS, count(decode(job, 'SALESMAN', 1, null)) SALESMANS
             from emp group by job)
    

    I don't really see a good use case for aggregations of 'double'-, but rather that he could give you undetected bugs in your code, if you happen to do double aggregation without noticing.

    Interesting thing to know ;-)

  • Can't understand why this query returns multiple lines with the same data

    Hi all
    I am a relative novice and self-taught when it comes to SQL. I wrote a query to our reporting tool that returns multiple rows, and I can't understand why. I know that I can use the SELECT DISTINCT option, but it really slows the execution when I do. I'd really rather understand if I can change the code to avoid the multiples. This is the query. I've included a few statements in italics to help explain the break. Any ideas?

    SELECT MATSITE, MATPONUM, FIRSTRECPTDATE
    Of
    Subquery that concludes the first date on which purchase orders have been implemented with ACK State
    (SELECT ACKSTAT. PONUM AS 'ACKPONUM', (MIN (ACKSTAT. CHANGEDATE)) AS 'FIRSTACKDATE '.
    OF PZMAX. POSTATUS ACKSTAT
    WHERE (ACKSTAT. STATE = 'ACK') AND (ACKSTAT.ORGID ='CGSALTUS)
    GROUP OF ACKSTAT. PONUM),
    Subquery that concludes the first reception against a purchase order transaction for purposes of comparison
    (SELECT TRANS. PONUM AS "MATPONUM", TRANS. SITEID AS 'MATSITE', (MIN (TRANS. TRANSDATE)) AS 'FIRSTRECPTDATE '.
    OF PZMAX. MATRECTRANS TRANS
    WHERE (TRANS.ORGID ='CGSALTUS) AND (TRANS. HOUR > =: startDate and TRANS. TRANSDATE < =: endDate)
    TRANS GROUP. SITEID, TRANS. PONUM)
    WHERE
    (ACKPONUM = MATPONUM AND FIRSTRECPTDATE < FIRSTACKDATE) OR (NOT EXISTS (SELECT 1 FROM PZMAX. POSTATUS ACKSTAT2 WHERE (ACKSTAT2. PONUM = MATPONUM) AND (ACKSTAT2. STATE = 'ACK') AND (ACKSTAT2.ORGID ='CGSALTUS)))

    The where the instruction is intended to find when one of two conditions exists. ((1) received happened before the command either in ACK or 2) a reception that's happened, but the purchase order is never in ACK State. It seems that this second condition that creates multiple lines.

    Any thoughts will be appreciated geratly.

    Dave Teece
  • That means 1e9 and why this query does not work?

    What does 1e9? Someone has links to documentation on this oracle? And why I get this error?
    SQL> select segment_name,(bytes/1e9) AS size from dba_segments where segment_name='MSG_MASTER';
    select segment_name,(bytes/1e9) AS size from dba_segments where segment_name='MSG_MASTER'
                                       *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected

    SIZE is a keyword - so if you want the name of the column size then use 'SIZE' else give it a different name

    Try dividing by other exponentials, then you'll see how: 1e0 1e1 (div 1), (div by 10), 1e2 :-) etc

    Mette

    Published by: mettemusens on 2009-05-12 16:02

  • Why this query SQLLite returns the same all the time?

    Hello

    I use a search box to accept a query on three columns and am page before based on the last record, which in this case is Run Baby Run by Loopy

    I know for a fact that the database has a song inside by Loopy called Straight Down the Line, so this should at least be showing that. But it does is display the same songs again.

    Can someone explain the error in my logic here?

    SELECT * WHERE DiscID AS "loopy %" songs or artist LIKE 'loopy %' or AS "loopy %" title AND artist > = 'LOOPY' COLLATE NOCASE Title > = 'Run Baby Run' COLLATE NOCASE ORDER BY artist COLLATE NOCASE ASC, title COLLATE NOCASE ASC LIMIT 20

    Thanks for taking a peek.

    This is a forum for AS3, not SQL - etc., which may explain the slow Pickup on your ad.  While someone might offer something at some point, you should try to find a forum where they discuss SQL programming, which could mean going out of the domain of Adobe.  The closest thing I can think that would be a forum in the Adobe forums game...

    http://forums.Adobe.com/community/Dreamweaver/server_side

  • Why this query does not work on the CF when it works fine on MYSQL?

    Subject says it all. I can run it through console mysql and get the result that I need, but when I place it inside a cfquery that he will not treat.

    SET @saldo = 20000;
    SELECT
    IF (Co.transtipo=0,@saldo:[email protected],@saldo:=@saldo+t.transmonto),
    @saldo: = @saldo - t.transmonto.
    t.TransID,
    t.cuentaid,
    t.operacionid,
    t.fechatrans,
    t.voucher,
    t.cheque,
    t.transtitular,
    t.transmonto,
    t.transdetalle,
    t.modificado,
    Co.transtipo,
    Co.Operacion
    OF cuentastrans t
    LEFT JOIN cuentasoperacion co ON t.operacionid = co.operacionid
    WHERE the t.cuentaid = 7
    ORDER BY t.fechatrans ASC

    Fixed, coldfusion must be labeled with 'AS' of the expressions in the opposite case he used to index the column.

  • Double required partitioning in this query?

    Hi friends

    Oracle version I use is: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64 bit Production
    With partitioning, OLAP and Data Mining options

    I have a scenario where a single account can be linked to two clients. Therefore, in the table having many lines for a single account. Examples of data include:
    Account_ID | product_code | cust_id | relationship_code | entity_code 
    
    1111 | ABC | 1234 | SOL | CUST 
    1111 | ABC | 2222 | ZZZ | LINK
    2222 | ABC | 7890 | SOL | CUST 
    2222 | ABC | 5678 | ZZZ | LINK
    3333 | JFK | 5878 | SOL | CUST 
    3333 | JFK | 3254 | SOL | CUST
    4444 | JFK | 2535 | SOL | CUST 
    4444 | JFK | 4565 | SOL | CUST
    In this scenario, I need two different outputs:

    Output 1: Keep these accounts with relationship_code = "ZZZ". The output is in accordance with the following:
    Account_ID | product_code | cust_id | relationship_code | entity_code 
    
    1111 | ABC | 2222 | ZZZ | LINK
    2222 | ABC | 5678 | ZZZ | LINK
    Exit 2: There will be a lot of accounts will not have relationship_code = "ZZZ". In this case, keep the account numbers, less the number of customer. For example in the list above, if we see the last four rows of 3333 and 4444 account id, I want to have the following result:
    Account_ID | product_code | cust_id | relationship_code | entity_code 
    
    3333 | JFK | 3254 | SOL | CUST
    4444 | JFK | 2535 | SOL | CUST 
    I used the following query:
    DELETE FROM temp_table tar
          WHERE EXISTS (
                   SELECT 1
                     FROM (SELECT account_id
                                , product_code
                                , cust_id
                                , relationship_code
                                , entity_code
                                , (ROW_NUMBER () OVER (PARTITION BY account_id, product_code ORDER BY account_id, product_code, relationship_code desc  )
                                  ) rn
                             FROM temp_table) src
                    WHERE src.rn > 1 
                      AND tar.account_id = src.account_id
                      AND tar.product_code = src.product_code
                      AND tar.cust_id = src.cust_id
                      AND nvl(tar.relationship_code,'ZZZ') = NVL(src.relationship_codep,'ZZZ'));
    This query gives me the correct result for output 2. But not for output 1. How can I achieve this?
    TUBBY_ORCL?select * from temp_table;
    
                  COL1 COL               COL3 COL COL5
    ------------------ --- ------------------ --- ----
                  1111 ABC               1234 SOL CUST
                  1111 ABC               2222 ZZZ LINK
                  2222 ABC               7890 SOL CUST
                  2222 ABC               5678 ZZZ LINK
                  3333 JFK               5878 SOL CUST
                  3333 JFK               3254 SOL CUST
                  4444 JFK               2535 SOL CUST
                  4444 JFK               4565 SOL CUST
    
    8 rows selected.
    
    Elapsed: 00:00:00.16
    
    delete temp_table
    where rowid in
    (
       select the_rowid
       from
       (
          select
             col3,
             col4,
             rowid as the_rowid,
             count(case when col4 = 'ZZZ' then 1 end) over (partition by col1) as has_z,
             min(col3) over (partition by col1) as min_col3
          from temp_table
       )
       where (has_z = 1 and col4     != 'ZZZ')
       or    (has_z = 0 and min_col3 !=  col3)
    );
    
    4 rows deleted.
    
    Elapsed: 00:00:00.09
    TUBBY_ORCL?select * from temp_table;
    
                  COL1 COL               COL3 COL COL5
    ------------------ --- ------------------ --- ----
                  1111 ABC               2222 ZZZ LINK
                  2222 ABC               5678 ZZZ LINK
                  3333 JFK               3254 SOL CUST
                  4444 JFK               2535 SOL CUST
    
    4 rows selected.
    
    Elapsed: 00:00:00.14
    TUBBY_ORCL?
    
  • When a computer XP starts, the following errors occur. Can't find Mac addresses, can't find DHCP at startup. PC is not connected to a network. Why would it gives this error at startup.

    When a computer XP starts, the following errors occur. Can't find Mac addresses, can't find DHCP at startup. PC is not connected to a network.

    Why would it gives this error at startup?

    It is not a Windows problem, it happens very early in the boot process until Windows is still a part of the image.  Your computer is configured for a remote network via PXE boot and there is no this PXE server so that you get this error message.  With PXE network boot, you can start a computer without him having a hard drive, the operating system resides on another machine on the network.  When the BIOS does not find the PXE server it gives you the error message, and then it proceeds to the next start equipment, which is probably your local hard drive.  Go into the BIOS and disable the PXE boot option or move it to the bottom of the boot order so that the hard drive is set as the primary boot device.

    John

  • Why between date is not return data for this query?

    Hello
    I have a table with this structure and I write this query to retrieve a few lines based on certain conditions, but this query returns no data. Can you please tell why?
    ID     DT
    
    003     11/8/2011
    002     10/8/2011
    001     9/8/2011
    And the execution of the query:
    SELECT * FROM TABLE_NAME WHERE DT BETWEEN TO_DATE('08/08/2011','dd/mm/yyyy') AND TO_DATE('12/08/2011','dd/mm/yyyy');
    Published by: starting August 13, 2011 07:10

    >

    >

    But what is the problem with that, why this date does not match when I'm providing the date format?

    What part don't you understand? You have not used TO_DATE when inserting data and default date format is dd/mm/yyyy, right? Same default date format is used if you are running:

    SELECT * FROM TABLE_NAME

    Original of your post States select returns above:

    ID     DT
    
    003     11/8/2011
    002     10/8/2011
    001     9/8/2011
    

    So the dates that you inserted are November 8, 2011, October 8, 2011-September 8, 2011. TO_DATE('08/08/2011','dd/mm/yyyy') is now August 8, 2011 and TO_DATE('12/08/2011','dd/mm/yyyy') is August 12, 2011. Then of course:

    SELECT * FROM TABLE_NAME WHERE DT BETWEEN TO_DATE('08/08/2011','dd/mm/yyyy') AND TO_DATE('12/08/2011','dd/mm/yyyy').

    will return all the lines. Bottome line - never write code that uses the implicit conversions date since your code becomes dependent on the NLS client settings and maybe working for a client and fail or produce erroneous results for other customers.

    SY.

  • Nothing wrong with this query?

    I tried to create a report based on this query:

    SELECT call_type.call_type_detail, code_city.code_city_detail, area_code.area_code_detail, call_reason.call_reason_detail, cform.cform_phone_number_body, call_outcome.call_outcome_detail, outcome_reason.outcome_reason_detail, cform.cform_date_time, cform.cform_comments
    OF call_type code_city area_code, call_reason, Carousel, call_outcome, outcome_reason

    I checked all the fields to make sure they match, and when I try to test CFR blocks... any idea why this may be the case? Thank you!

    The funny is I was already using inner join, but did not know who called him and not add to the post because I have quite a few variables as criteria and thought that it would make it difficult to understand. Ultimately it was stalled due to an error in a table, that I was not specified correctly.

    That's what I had from the start!

    SELECT call_type.call_type_detail, code_city.code_city_detail, area_code.area_code_detail, call_reason.call_reason_detail, cform.cform_phone_number_body, call_outcome.call_outcome_detail, outcome_reason.outcome_reason_detail, cform.cform_date_time, cform.cform_comments

    OF call_type code_city area_code, call_reason, Carousel, call_outcome, outcome_reason

    WHERE cform.cform_date_time BETWEEN #CreateODBCDateTime (param. CustomFullStartDate) # AND #CreateODBCDateTime (param. CustomFullEndDate) # AND cform.cform_call_product = #param. Cform.call_service = GetCustomProduct # AND #param. GetCustomService # AND cform.cform_call_reason = #param. GetCustomCallReason # AND cform.cform_call_outcome = #param. GetCustomCallOutcome # AND cform.cform_call_outcome_reason = #param. GetCustomReason # AND call_type.call_type_id = cform.cform_call_type AND call_city.call_city_id = cform.cform_call_city AND area_code.area_code_id = cform.cform_area_code AND call_reason.call_reason_id = cform.cform_call_reason AND call_outcome.call_outcome_id = cform.cform_call_outcome AND outcome_reason.outcome_reason_id = cform.cform_outcome_reason AND cform.cform_date_time

  • Why this erroneous query works well? -Answer

    DB version: 10 gr 2
    I wanted to reproduce the non-use of rownum when used with an ORDER BY clause.
    Because ORDER BY is evaluated finally (after ROWNUMs are generated), the query below give bad result put most of the time.
    But the following query
    select ename,join_date
    from test
    where rownum<4
    order by join_date
    give me a correct result. Then, when this query will start to give erroneous results?


    alter session set nls_date_format='DD-MM-YYYY HH:MI:SS';
    
     SELECT SYSDATE FROM DUAL;
    
    SYSDATE
    -------------------
    15-12-2008 11:40:30
    
    create table test
    (ename varchar2(15),
    join_date date);
    
    
    insert into test values('JAMES',SYSDATE);
    insert into test values('CHESTER',SYSDATE);
    insert into test values('SUNITA',SYSDATE);
    insert into test values('GARRY',SYSDATE);
    insert into test values('KAREN',SYSDATE);
    insert into test values('ABDUL',SYSDATE);
    insert into test values('YING',SYSDATE);
    
    set lines 400
    select * from test;
    
    ENAME           JOIN_DATE
    --------------- -------------------
    JAMES           15-12-2008 11:41:21
    CHESTER         15-12-2008 11:41:40
    SUNITA          15-12-2008 11:41:56
    GARRY           15-12-2008 11:42:17
    TIM             15-12-2008 11:42:44
    KAREN           15-12-2008 11:52:46
    ABDUL           15-12-2008 11:53:01
    YING            15-12-2008 11:53:18
    CHAICE          15-12-2008 12:14:27
    THELMA          15-12-2008 12:14:54
    
    
    select ename,join_date
    from test
    where rownum<4
    order by join_date;
    
    ENAME           JOIN_DATE
    --------------- -------------------
    JAMES           15-12-2008 11:41:21   --correct
    CHESTER         15-12-2008 11:41:40   --correct     
    SUNITA          15-12-2008 11:41:56   --correct
    Published by: Nichols on December 15, 2008 03:37

    Published by: Nichols on December 15, 2008 03:56

    Published by: Nichols on December 15, 2008 04:09

    Run the same query, but the order of join_date DESC. You will see that the result is completely incorrect.
    The query takes just three records (not the 'top three' - there is no order) and then ordered these records based on the ORDER BY in the final predicate.

Maybe you are looking for

  • Unable to access Web sites using Adblocker most recent

    It has been wonderful using your Adblocker Plus feature, but lately, when I visit sites or playing games as I usually do, I can't access them until anti-ad is disabled. These areas become wise or something has changed since your last update to 5.0?

  • laptop Pavilion 17 t: SimplePass fingerprint reader without?

    I just got the laptop Pavilion 17 t.  One of the pre-loaded applications is HP SimplePass.  My computer lacks a fingerprint reader. Have 2 questions: This software will do anthing for me the usual password save dilemma without the fingerprint reader?

  • Lenovo Ideapad U550 Driver for Windows 8

    I'm looking for the Ideapad U550 Windows 8 drivers, after update from Windows 7 to Windows 8. It works, but some things don't. The graphics card and does not work and also the camera is not supported. Would be happy to help, or even all of the necess

  • loading 32-bit programs on a 64-bit system

    I just bought a Compaq 64 bit Windows 7. I want to load an older copy of civilization (civ2) top and it seems to load, but it won't work. The message I get is that it does not find c:\windows\system32\original. I'm assuming that as my computer is 64-

  • KB971029 is offered, but receive error message 'not applicable for this system.

    I had some freezes during the game Fallout3, so I got out and checked the update of Windows, because it is Tuesday, and I thought maybe it was attempts to update that was the problem. While you wait for the update to initialize, I went to the event v