0

I have used the dense rank to group the items in the table into 3 days bucket. Example: 22-24 April will be 'tight up' together and assigned priority as 4.

enter image description here Question:

  1. I need to do the further sorting on Planning_package based on the QTYORDERED. The final result for priority 4 as below. enter image description here

The sql I use to perform the sorting as below. Anyone can help can help to do the further sorting on planning_package??? **

select SALESORDERID, ITEM, PLANNING_PACKAGE, GENERIC_PACKAGE, QTYORDERED,
DMD_TYPE_CD, ORDER_TYPE_CD, PRIORITY_NBR,PROMISEDAVAILDATE,
dense_rank()
over
(
order by
    round((
            case when dmd_type_cd = 'Netted Forecast'
                 then greatest(PROMISEDAVAILDATE, (to_date('22-Apr-14','DD-Mon-YY')+31)) 
                 else PROMISEDAVAILDATE end
            - (to_date('22-Apr-14','DD-Mon-YY')+1)) / 3, 0) desc
) as priority

from
TEST_SALESORDER_TABLE;

1 Answer 1

0

You can specify multiple column to sort by the in order by clause - in your case it will be .... order by priority , qtyordered desc

If priority is an expression you can order by column position as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.