Oracle SQL Statement Order By -


i have got following query:

    column index_name format a15 heading "index_name"     column column_name format a15 heading "column_name"     column column_position format 999999 heading "column_position"      select index_name, column_name, column_position     all_ind_columns     table_owner = 'abc' 

the returned result follows:

    index_name      column_name     column_position     --------------- --------------- ---------------     sys_c007963     c_uname                       1      order_line_pkey ol_id                         1      order_line_pkey ol_o_id                       2      orders_pkey     o_id                          1      item_pkey       i_id                          1      customer_pkey   c_id                          1      country_pkey    co_id                         1      cc_xacts_pkey   cx_o_id                       1      author_pkey     a_id                          1      address_pkey    addr_id                       1        10 rows selected  

how change sql statement such sort according number of repeated index_name in ascending order?

for example this:

    index_name      column_name     column_position     --------------- --------------- ---------------     sys_c007963     c_uname                       1       orders_pkey     o_id                          1      item_pkey       i_id                          1      customer_pkey   c_id                          1      country_pkey    co_id                         1      cc_xacts_pkey   cx_o_id                       1      author_pkey     a_id                          1      address_pkey    addr_id                       1      order_line_pkey ol_id                         1      order_line_pkey ol_o_id                       2       10 rows selected  

you can count number each index , order that:

select index_name, column_name, column_position (select index_name, column_name, column_position,              count(*) on (partition index_name) cnt       all_ind_columns       table_owner = 'abc'      ) t order cnt, index_name 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -