Search code examples
sqloracle11g

what does order 1,2 do


Imagine we have following table

create table t
  (item number,
   bin number,
   primary key (bin , item) );

I have used insert into command to insert several values into table t, now i am interested in what does this code

select * from t
  order by 1,2;

As far as i know it selects everything from table t and sorts it, because order means to sort selected query using condition listed in order command, but order 1,2 i could not understand what does it means, could you help me ?


Solution

  • It sorts the result by the first and second column, so in your case it's identical to

    select *
    from t
    order by item, bin;