Thursday, 12 September 2013

dense ranking based on a quantity field without distinct join on two tables

dense ranking based on a quantity field without distinct join on two tables

I have a very strange requirement at site, I have two tables Header and
Details. I can join on two fields [Item Code] and [Contract Number] but
they are not unique. But the end result which they are expecting is to
select the records from the details table based on a quantity field in
header. I know this sounds crazy but they dont have any other distinct
joins.
Ex: Header table
Item code |Contract Number | Quantity
1000 50000 2 1000 50000 3 1000 50000 2
Item Table
Item code |Contract Number | Work Order
1000 50000 abc 1000 50000 def 1000 50000 ghi 1000 50000 jkl 1000 50000 mno
1000 50000 pqr 1000 50000 stv
Now, I need to pick the work orders based on quantity i.e for first row in
header with quantity 2 I need to pick first two records in Item table and
like wise.
Need to fix ASAP. Could anyone help tackle this issue?
Millions of thanks in advance!!!!!!!
Prabhu

No comments:

Post a Comment