Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need to display top 10 ranks without duplicate

LRKJun 27 2017 — edited Jun 27 2017

Hi Guys,

I have one query that its is giving top 10 ranks but there is duplicate rank.

SELECT id

              , l_count

              , DENSE_RANK() OVER (ORDER BY l_count DESC) l_num_count

              , name

              , n.cn

              , pa_number

              , 'ACTIVE'

           FROM (  SELECT l_id

                        , o_id

                        , p_number

                        , COUNT(ps_num) l_count

                     FROM queue

                    WHERE     create_date > SYSDATE - 30

                          AND UPPER(req_type) IN

                                 ('MANU', 'AUTO')

                          AND ps_stat_code =100        

                 GROUP BY l_id, o_id, p_number) c

              , prod p

              , fac f

              , cn n

          WHERE     c.pa_number = p.p_number

                AND f.l_id = c.o_id

                AND n.l_id = c.l_id;

this query is giving duplicate ranks, if l_num_count is having duplicate, we need to consider create_date. I mean based on the latest date is first.

Can some one help me on this to get proper resulted ranks.

Rrgrds,

KLR

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2017
Added on Jun 27 2017
2 comments
711 views