Columns in the WHERE clause - order affect the output?

I work on some queries to feed a DWH and stumbled upon this question. Let's say I have this query:
(SELECT ARTREGNROS FROM gx.artabo aa,gx.toccab tc1
                where aa.artid=tc1.artid
                and t.tocid=tc1.tocid
                and aa.abocod=c.abocod
                and aa.artconcod=c.concod
                and aa.percod=a.percod
                and aa.ArtAboFlgA='S'
                ) Tarjeta
The exit will happen anyway if I do like this:
(SELECT ARTREGNROS FROM gx.artabo aa,gx.toccab tc1
                where aa.artid=tc1.artid
                and a.percod=aa.percod
                 and aa.ArtAboFlgA='S
                and tc1.tocid=t.tocid
                and c.abocod=aa.abocod
                and aa.artconcod=c.concod
                 ) Tarjeta
I guess what he used, or at least I him did not change with the data that I use, but I thought to check here once just to have peace of mind. Maybe it's not the happiest example, but I guess the question is clear

No difference.

Tags: Database

Similar Questions

  • 'create columns with a where clause' in MDB

    Hi all

    I have a question on the OBI EE meta data layer.

    We have OBIEE sitting on a with a star schema data warehouse.

    Our fact table contains the following fields...

    EmployeeID
    CompanyID
    ID of the measure
    The measure name
    MEASURE

    That's what we have in the physical layer, layer MDB and the presentation layer, but I want to be able to "create columns with a where clause.

    So my table of facts in the presentation layer would look like this

    Quantity sold
    Unit cost
    Amount of the company



    I thought I could just create a logical with column

    Quantity = measurement
    where as name = "quantity".

    But I can't find any to do so.

    Any ideas?


    Thank you

    Hello

    I think that what you want to achieve must be done in the physical layer and not the business layer.
    Instead of using your physical table directly from the DB, you must create a physical table based on an SQL statement.
    GO to the physical layer you / create the new object table in Table type choose "Select" and then you write your select statement as you want.
    Once this is done to create your physical joins and import your table into your business layer and create your complex joins
    This should do the trick.
    It may be useful

    Concerning

  • TARGET column in the output of crs_stat

    That said to TARGET what doc oracle on the column in the output of crs_stat
    http://docs.Oracle.com/CD/B19306_01/RAC.102/b14197/crsref.htm

    The TARGET value shows the State in which Oracle Clusterware tries to define the resource. If the TARGET value is ONLINE and a cluster node fails, then Oracle Clusterware tries to restart the application on another node if possible. Is there a condition requiring a resource STATE of being offline, as a required resource is offline, then the TARGET value remains online and Oracle Clusterware tries to start the application or an application resource once the problem is corrected.

    Don't quite understand. So, if
    TARGET = ONLINE , then that means this particular resourse should be up mandatorily ?
    and if
    TARGET = OFFLINE , then that means this particular resourse does not have to be up ?
    Question2.
    Can someone tell me a scenario for a standard implementation of CARS, where you can find the TARGET = OFFLINE

    GarryB wrote:
    So, if

    TARGET = ONLINE , then that means this particular resourse should be up mandatorily ?
    and if
    TARGET = OFFLINE , then that means this particular resourse does not have to be up ?
    

    It's also the way I understand it.
    >
    >
    >

    Question2.
    Can someone tell me a scenario for a standard implementation of CARS, where you can find the TARGET = OFFLINE

    Such as in the 11.2 CARS:
    -ora.gsd is in offline mode by default because it is only necessary if you are using an Oracle 9.2 database according to http://docs.oracle.com/cd/E11882_01/install.112/e24616/postinst.htm#BABDAFGD.
    -ora.oc4j is offline because it has not been implemented by Oracle. For example in http://docs.oracle.com/cd/E11882_01/rac.112/e17264/install_rac.htm#TDPRC175.

  • Details on the order of columns in a Where Clause

    Hi All
    My both Quarries  are giving same record count .
    so  can  i say that the order of the columns("msib.inventory_item_id=pol.item_id" AND" pol.item_id=msib.inventory_item_id ") 
    in the where  clause doesn't effect the query result in any situation 
    {code
    }
    select count(*)
    from po_headers_all poh
       ,po_vendors pv
       ,po_lines_all pol
       ,po_line_locations_all pll
       ,mtl_system_items_b msib
    where poh.vendor_id = pv.vendor_id
    and poh.po_header_id = pol.po_header_id
    and pol.po_line_id = pll.po_line_id
    and pll.ship_to_organization_id = msib.organization_id ----------------1
    and msib.inventory_item_id=pol.item_id --------------------------2
    and poh.type_lookup_code = 'STANDARD'
    and pv.vendor_name = 'Star Gate Ltd'  
    group by 1
    
    select count(*)
    from po_headers_all poh
       ,po_vendors pv
       ,po_lines_all pol
       ,po_line_locations_all pll
       ,mtl_system_items_b msib
    where poh.vendor_id = pv.vendor_id
    and poh.po_header_id = pol.po_header_id
    and pol.po_line_id = pll.po_line_id
    and pol.item_id = msib.inventory_item_id  ----------------------------------2 
    and pll.ship_to_organization_id = msib.organization_id -----------------------------1 
    and poh.type_lookup_code = 'STANDARD'
    and pv.vendor_name = 'Star Gate Ltd'  
    Thank you

    Published by: vijay539 on November 20, 2009 09:17

    Published by: vijay539 on November 20, 2009 09:18

    Published by: vijay539 on November 20, 2009 09:19

    Published by: vijay539 on November 20, 2009 09:19

    Hello

    Right; the order in which the columns appear in the SELECT clause has nothing to do with the lines that are in the result set.

    In fact, unless you say SELECT DISTINCT , I don't think there's anything (except to trigger an error) you can do in the SELECT clause, which would change the lines are selected.

    Published by: Frank Kulash, November 20, 2009 12:45

    Sorry, I misread the question. You may have about the order of the conditions in the WHERE clause, not the SELECT clause.

    The answer in short is the same:
    Right.

    Unless you mix ANDS and ORs (no one should ever do and that you are not), the order of the conditions will make no difference in the results.

  • How to set a null column in a where clause clause involving a statement box

    In oracle APEX, I a (selection list) element called: P32_STATUS. It contains two values of interest (for this discussion): 'Available' and 'checked '. In my report, I have a column called vc_status that contains two values: "Checkbox" and NULL. In my application I want to use a case statement in my where clause similar to the lines of

    where

    .

    .

    .

    AND (vc_status = CASE WHEN: P32_STATUS = "Checkbox" THEN : P32_STATUS )

    WHEN : P32_STATUS = 'Available' THEN NULL END)

    The 'box' filtering works but the filtering to try to vc_status the NULL value does not work. Can someone help me? Thank you!

    (P.S. My intuition says that there because I can not put vc_status = NULL, but I must say that vc_status IS NULL... However, I don't know how to do execution IS ZERO inside a CASE statement)

    Hello

    Your intuition is right...

    In Oracle NULL is a bit special:

    NULL = NULL is false

    NULL <> NULL is false

    Thus, instead of the parameter a NULL value in the CASE WHERE there is just set a value on the other side:

    NVL (vc_statut, 'Available') =: P32_STATUS

    That's all! Simple, clean and functional

  • Alignments of column in the output HTM

    Hello. I have a SQL script below which shows 3 columns in a HTM file. It works without error, but I noticed that when the display the output HTM column names are centered, but the column values are all justified to the left. Despite everything I've tried I can't seem to get the names of the columns to align left or column values to focus. Note that in the code below, I tried to use the option JUSTIFY opition on every column, but he seems to have no effect in the output.

    Can anyone help?


    fixed term
    trigger the echo;
    Set feedback off;
    game check
    put in head
    set of 99 pages;
    set pagesize 50;
    set linesize 80;
    SET MARKUP HTML ON SPOOL ON HEAD 'report ADDS < TITLE > < /title >-
    "< STYLE TYPE =" TEXT/CSS"> <!-BODY {background: ffffc6}-> < / STYLE >.
    coil/usr/IBM/WebSphere/AppServerCommunityEdition/repository/default/TTMSWeb/12
    22365662123/TTMSWeb-1222365662123.war/scanner_returns_report.htm;
    TTITLE "Scan Returns";
    Col Device_Status format a13 HEADING "Device status" JUSTIFY LEFT;
    Col Total format a5 HEADING "Total" JUSTIFY CENTER;
    Col format a15 SECTION staff "Staff" JUSTIFY RIGHT;
    Select b.device_status Device_Status, rtrim (count (a.reporter)) Total, c.first_na
    me | » '|| c.last_name |' ('| c.Guid |') ' Staff
    of scanner_assignment a, scanner_inventory b, pwc_employee c
    where a.manufacturer_nm = b.manufacturer_nm
    and a.serial_num = b.serial_num
    and a.modify_by = c.guid
    and trunc (a.return_dt) = trunc(sysdate-1)
    and a.modify_by = '& 1' '.
    and b.device_status = '0'
    and b.device_status in ('0 ','8 ')
    Group of c.first_name |' '|| c.last_name |' ('| c.Guid |') ", b.device_status
    order of c.first_name |' '|| c.last_name |' ('| c.Guid |') ', b.device_status;
    spool off;
    output
    /

    I can't get the names of the columns to align left or column values to focus.

    Extend your style orders of sheet with the direction of alignment, for example

    for example:

    SQL> set markup html on entmap off head "" spool  on
    
  • WHERE clause order ox performance question

    I do not understand order of execution of a WHERE clause, the use of a complex database

    I want to write a SELECT statement with the following condition

    ... WHERE (branch = 'main') AND (type = 1) OR (AND the costs-1 = 2).

    My question is

    < 1 > yoyu can use parentheses within a WHERE clause

    < 2 > how you would write such a clause as above if you cannot use parenthesis

    Thank you

    Hello

    Yes, you can have parentheses in a WHERE clause.
    I highly recommend to use when you need to use both AND and or in the same WHERE clause, since

    WHERE  (    x
            AND y
            )
    OR      z
    

    is not the same as

    WHERE   x
    AND     (   y
            OR  z
            )
    

    As others have said:

    ( charge -1 AND charge = 2 )
    

    will cause a compilation error.
    Here's the syntax valid and quite reasonable (although somewhat obscure):

    WHERE     (     branch = 'main'
         AND     type    = 1
         )
    OR          (     charge != -1
            AND     charge !=  2
         )
    
  • Control width of column in the output of the Script?

    I want to use the button "Run the Script" (NOT execute statement) to run a SQL. I want an output text is easier to read (fixed-width fonts!) and save. The problem is that it is impossible to control the column width. SQLPlus style 'column' does not work. And even a few substr(), trim(), the column is completed up to the length (?) original.

    For example, I want to display code source PLSQL USER_SOURCE:
    select text from user_source
    order by  name, type, line
    SQLDeveloper pads the output to 4,000 characters (?), which makes the unusable output (for example, to save or even look at one). Using functions like the function rtrim(), substr() does not help.

    Because SQLDeveloper is displayed not correctly output of SQL, SQLPlus is still irreplaceable. But you need everything to prevent it kicked away from the buffer to the coil.

    (OK I know that I can use dbms_metadata in this case.) But this is just one example...)

    SQLDeveloper: 2.1.0.63
    OS: Windows XP SP2

    Published by: thtsang on July 13, 2010 11:43

    As you say, it's impossible.
    However, I suggest that you get 2.1.1 with a fixed-width font in the grid of statement Run As. Then use the export of the grid (menu) or CTRL-+ A CTRL + C (or CTRL-SHIFT-C with position) If you want to save.

    Have fun
    K.

  • Select simple lines that correspond to a column in the output of function group

    Writing a query that will search through a set of data that returns the codes bar of the CompoundNames who have a quantity amount > 500.

    Then if it ran against the sample table below the output would be
    0005
    0006
    0007
    0008
    0009
    0010

    Code bars, CompoundName, BatchId, quantity
    --------------------------------------------------------------
    0001, XE 1000, 1000 100 XE, 100
    0002, XE 1000, 101 1000 X 100
    0003, 102 1000 XE, XE 1000, 100
    0004, XE 1000, 1000 103 XE, 100

    0005, 2000 XE, XE 2000 100, 100
    0006, 2000 XE, XE 100, 2000 101
    0007, 2000 XE, XE 2000 102, 100
    0008, 2000 XE, XE 2000 103, 100
    0009, 2000 XE, XE 2000 104, 100
    0010, 2000 XE, XE 2000 105, 100

    0011, XE 3000, 3000 100 XE, 100


    I had this day

    Select CompoundName, Sum (Quantity) OF Table
    CompoundName GROUP
    HAVING Sum (Quantity) > 500)
    compoundname order;

    But I need every barcode corresponding to each batchid, while the total amount of lots is > 500.

    TIA

    Welcome to the Forum,
    The following approach will work for you.

    select distinct * from
    (
    Select Barcode, CompoundName, SUM(QUANTITY) over (partition by CompoundName) sumqty
    FROM Table
    )
    where sumqty > 500
    order by compoundname;
    

    TRN
    Sudhakar B.

  • Update one column of the other

    Hi guys,.

    I have two columns in a table, FIRSTNAME and LASTNAME. Currently, the firstname and lastname appear in the column "Firstname". I would separate the name of this column and insert in the "LASTNAME" column

    For example, here is what I currently have:

    Line: -.

    First name last name

    Peter Andre
    James Dean
    Men watch
    Jenna Klare
    James Smith
    Tina Adams
    Blair Witch


    Currently, my "Lastname" column is empty. I want to update the table to insert lastname in the "First NAME" field in the "LASTNAME" column, so the output will look like:

    First name last name
    Peter Andre
    James Dean
    Men watch
    Jenna Klare
    James Smith
    Tina Adams
    Blair Witch

    Help, please.
    Thanks in advance.

    Hello

    Maybe this,.

    SQL> with t As(Select 'Peter Andre' Name From Dual union all
      2            Select 'James Dean' Name From Dual union all
      3            Select 'Watch Man' Name From Dual union all
      4            Select 'Jenna Klare' Name From Dual union all
      5            Select 'James Smith' Name From Dual union all
      6            Select 'Tina Adams' Name From Dual union all
      7            Select 'Blair Witch' Name From Dual)
      8  SELECT regexp_substr(Name,'[^ ,]+' ) First
      9       , regexp_substr(Name,'[^ ,]+$') LastName
     10    FROM t;
    
    FIRST                                        LASTNAME
    -------------------------------------------- --------------------------------------------
    Peter                                        Andre
    James                                        Dean
    Watch                                        Man
    Jenna                                        Klare
    James                                        Smith
    Tina                                         Adams
    Blair                                        Witch
    
    7 rows selected
    

    or

    SQL> with t As(Select 'Peter Andre' Name From Dual union all
      2            Select 'James Dean' Name From Dual union all
      3            Select 'Watch Man' Name From Dual union all
      4            Select 'Jenna Klare' Name From Dual union all
      5            Select 'James Smith' Name From Dual union all
      6            Select 'Tina Adams' Name From Dual union all
      7            Select 'Blair Witch' Name From Dual)
      8  SELECT Substr(Name,1,Instr(Name,' ',1)-1) First
      9       , Substr(Name,  Instr(Name,' ',1)+1) LastName
     10    FROM t;
    
    FIRST                                        LASTNAME
    -------------------------------------------- --------------------------------------------
    Peter                                        Andre
    James                                        Dean
    Watch                                        Man
    Jenna                                        Klare
    James                                        Smith
    Tina                                         Adams
    Blair                                        Witch
    
    7 rows selected
    

    Kind regards
    Christian Balz

    Published by: Christian Balz on 2009-06-17 15:33

  • Order columns (which make up the primary key constraint) matter in where clause of DML query for use of indexing mechanism to operate.

    Version of DB: database Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production


    I have a table my_table as below:
    create table my_table
    (
    my_code varchar2 (6).
    my_id varchar2 (24).
    forced pk_1 primary key (my_code, my_id)
    );


    Primary_key here's a composite key that contains columns 1 (my_code) and 2 (my_id).
    Is there that a difference in the way below queries is executed in terms of performance (use of indexing in the extraction).

    (a) select * from my_table where my_code = '123' and my_id = "456";
    (b) select * from my_table where my_id = '456' and my_code = '123';


    The understanding I have the order of the column in the where clause should be identical to the sequence in
    What primary key draws for indexing to be used by oracle in oracle other DML queries ignores indexing
    However when I used explain plain both show the same query cost with single scan with index rowid.
    so I don't know if I'm wrong in the concept that I have. Kindly help.

    Thanks in advance,
    Gerard

    Your question is answered in the Performance Tuning Guide

    Using indexes and clusters

    14.1.4 choosing composite indexes

    A composite index contains several key columns. Composite indexes can provide additional benefits compared to the index to single column:

    • Improved selectivity

      Sometimes the two or more columns or expressions, each with a low selectivity can be combined to form a composite with a high selectivity.

    • Reduced IO

      If all columns selected by a query are a composite index, then Oracle may return these values in the index without access to the table.

    A SQL statement can use a path on a composite index if the statement contains constructions that use a main part of the index.

    Note:

    This is no longer the case with the skip index scans. See "Index Skip Scans".

    A main part of an index is a set of one or more columns that have been specified first and consecutively in the list of columns in the CREATE INDEX statement that created the index.

  • Question about the order of evaluation of the clause WHERE CLAUSE when the Oracle OF the syntax used to join tables

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article?

    Thanks in advance,

    Hello

    dariyoosh wrote:

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article? ...

    The reverse is actually closer to the truth, but we can't really make general statements like that.

    SQL is not a language of the proceedings.  Looking at the code SQL, we could say that the code does, but we cannot say much about how that code it.  In other words, SQL is a language that describes the results you get, not the way to get them.

    The optimizer will do everything what he thinks is faster if it does not change the results.  If any order in which they are applied (in outer joins or CONNECT BY queries, for example), then think of the join is done first, and the value of the WHERE clause is applied to the result of the join.

    Here is a query looks very much like you posted:

    SELECT d.deptno

    e.ename, e.sal

    OF scott.dept d

    LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno

    WHERE e.sal > = 3000

    ORDER BY d.deptno

    ;

    Output:

    DEPTNO ENAME SAL

    ---------- ---------- ----------

    10 KING 5000

    20 FORD 3000

    20 3000 SCOTT

    The scott.dept table contains deptnos 30 and 40; Why are they not in the result set?  The query behaves as if the outer join is made first (production 15 rows), then the WHERE clause has been applied.  All lines with deptno = 30 had sals down han 3000 and all single line with deptno = 40 was NULL in the sal column, then these lines are excluded (as well as other lines of deptnos 10 and 20), and only 3 lines above are left.

  • "Invalid column" on the place where several clauses with subqueries and cfqueryparam

    I see a behavior in the cfquery coldfusion I would like to find an exmplanation for.  I have a query that performs a subquery in the select part and if I have several where lines, I get a message 'invalid column name' to find out where my second article, but only when I'm with cfqueryparam

    For example, on what follows, I get "invalid column name «position_id»»

    SELECT department_staff_tbl.*,
    (SELECT max (bookmark_id)
    OF bookmarked_items_tbl
    WHERE item_id = department_staff_tbl.staff_id

    ) AS bookmark_id
    OF department_staff_tbl
    WHERE department_id = < cfqueryparam value = "" #arguments.deptid # "cfsqltype ="cf_sql_integer">"
    AND position_id = < cfqueryparam value = "" #arguments.posid # "cfsqltype ="cf_sql_integer">"
    AND staff_id = < cfqueryparam value = "" #arguments.staffid # "cfsqltype ="cf_sql_integer">"

    If I change the order of my where clause staff_id is first, and then he said "department_id" is an invalid column.

    If I don't have a where clause, it works.  (i.e. WHERE position_id = < cfqueryparam value = "" #arguments.posid # "cfsqltype =" cf_sql_integer">).

    If I remove the where clause of my subquery (WHERE item_id = department_staff_tbl.staff_id) it works.

    This also works if I remove the cfqueryparam where my article so that my query looks like this:

    SELECT department_staff_tbl.*,
    (SELECT max (bookmark_id)
    OF bookmarked_items_tbl
    WHERE item_id = department_staff_tbl.staff_id

    ) AS bookmark_id
    OF department_staff_tbl
    WHERE department_id = #arguments.deptid #.
    AND position_id = #arguments.posid #.
    AND staff_id = #arguments.staffid #.

    Any thoughts?

    A more conventional way to enter your data is without the subquery.  Something like that

    Select fields, the bookmarkid max (bookmark_id)

    from bookmarked_items__tbl join department_staff_tbl on staff_id = bookmark_id

    When etc.

    Some field group

  • Where is the installer for the Source column of the command in other tab of orders?

    Hello!

    I would like to ask where to find the installer for the Source column of the command in other tab of orders. I saw internal and online, I think it's always external.

    Thank you.

    Jon

    Order header Source is the origin of the order-using the OM Super user responsibility, see Setup-> controls-> import Sources.  I think that external is a Source Type on the command line that indicates if the line item will be provided by your org or bought.

  • What's the point of having several columns in the ORDER BY clause?

    DB version: 10 gr 2

    When you use the ORDER BY clause, the lines are always sorted by the first column in the ORDER BY clause. So, what's the point of having several columns in the ORDER BY clause (I always see this in production codes)?

    For the below SQLs' schema SCOTT, result sets are always classified according to the first column ename. When I added use asc and desc of employment, does not change the result set.
    SQL> select * from emp order by ename;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.
    
    SQL> select * from emp order by ename, job;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.
    
    SQL>  select * from emp order by ename, job desc;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    20
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
    
    14 rows selected.

    Search in this example, you will see the difference

    SQL> create table test_order (name varchar2(10), surname varchar2(10), age number);
    
    Table created.
    
    SQL> insert into test_order values('Kamran','Agayev',26);
    
    1 row created.
    
    SQL> insert into test_order values('Kamran','Taghiyev',26);
    
    1 row created.
    
    SQL> insert into test_order values('John','Kevin',23);
    
    1 row created.
    
    SQL> select * from test_order;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    Kamran     Agayev             26
    Kamran     Taghiyev           26
    John       Kevin              23
    
    SQL> select * from test_order
      2  order by age;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    John       Kevin              23
    Kamran     Agayev             26
    Kamran     Taghiyev           26
    
    SQL> select * from test_order
      2  order by age asc, surname desc;
    
    NAME       SURNAME           AGE
    ---------- ---------- ----------
    John       Kevin              23
    Kamran     Taghiyev           26
    Kamran     Agayev             26
    
    SQL>
    

    When in the second query, I sorted out only for age, you saw it there two 26 years old Keita, there was first Agayev, then Taghiyev. But if I want to get the family names in descending order when there are two very old person, then I will add the second column in the order by clause

    - - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev a. (10g OCP)
    http://kamranagayev.WordPress.com

Maybe you are looking for