Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback, please email oracle-forums_moderators_us@oracle.com

Sorting the data set

2652054Jul 10 2020 — edited Jul 11 2020

Hi Experts,

I have the below data set for sales order and sequence in a table. This table is at vendor location and I access the data via dblink. I can only select these two columns. Now i need to  select in such a way that i select distinct so numbers but it should be in the sorted as per below table ,i.e. 7037561280,7037567671,7037633589,7037630443,7037627397,7037601762 ....7037619156. If i do a select distinct or group by so number , i get distinct values but they are not in the same order as below . I tried using RANK and DENSE_RANK function as below to check if i can use these to get the desired output. But it does not work because when i do a partition by so-number , the rank again begins with 1.

Hence can you help me/guide me to get the sorted so_number from below data set. I used below script

            SELECT so_number

                         ,seq_no,

                       DENSE_RANK() OVER (PARTITION BY so_number ORDER BY seq_no) AS myrank

          FROM    

                      xx_om_sellout_data        

          order by seq_no

so_numberseq_no
70375612802
70375612803
70375676714
70375676715
70375676716
70375676717
70376335898
70376335899
703763044310
703763044311
703762739712
703762739713
703760176214
703760176215
703759636416
703759636417
703761915618
703761915619

Regards,

This post has been answered by Solomon Yakobson on Jul 10 2020
Jump to Answer
Comments
Post Details
Added on Jul 10 2020
8 comments
127 views