SQL

 1) Index

2) How to find 2nd,3rd or Nth highest salary from a table

select * from( select emp_id,emp_name, sal, dense_rank() 
       over(order by sal desc)r from Employee
     ) 
where r=&n;

To find to the 2nd highest sal set n = 2
To find 3rd highest sal set n = 3 and

2) Rowid and Rownum

SELECT   MIN (list_header_id)
    FROM qp_list_headers_b
   WHERE TRUNC (last_update_date) >
              TRUNC (SYSDATE)
            - NVL (fnd_profile.VALUE ('SRI_QP_DENORMALIZE_WRAP_NO_DAYS'),7)

SELECT DECODE (SUBSTR (:$flex$.qp_conc_update_type,
                       1,
                       LENGTH (:$flex$.qp_conc_update_type)
                      ),
               'ALL', :$flex$.list_header_id_low:NULL,
               'HEADER_PHASE', :$flex$.list_header_id_low:NULL,
               'DENORMALIZED', :$flex$.list_header_id_low:NULL,
               'QUAL_IND', :$flex$.list_header_id_low:NULL,
               '~'
              )
  FROM DUAL

0 comments:

Post a Comment