Skip to content
Advertisement

Selection based on multiple conditions

I have a requirement to select Customers based on the Channel and Organisation i.e., the order of selection of Customers should be based on Channel – 10,40,20,30 and all the organisations for that customer needs to selected as well.

For Eg if a customer has a Channel 10 and 40 – then Channel 10 takes a priority over 40 and so on. Also, For every Customer, if they have 2 Organisations, then they both need to be selected.

enter image description here

Hope I am clear. Please can somebody help me with this query.

Advertisement

Answer

You can use Oracle’s KEEP FIRST to apply an order of precedence:

The same can be achieved with the standard-complient ROW_NUMBER:.

Add a WHERE clause, if you want to restrict this to certain customers, channels or organizations.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement