Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Sample tabel T0

Sno ID LOT_ID ITEM_NUM
14 1 abc123 2
18 2 abc123 5
20 3 abc123 3
22 4 abc123 4
23 5 abc123 8
15 1 xyz456 4
16 1 pqr234 8
17 1 lmn333 4
21 2 lmn333 8
19 3 lmn333 4

Let Suppose X = 7 (Total number of Items required for specified LOT = abc123)
Desired Output :

Sno ID LOT_ID ITEM_NUM
14 1 abc123 2
18 2 abc123 5

*Note: Atleast one should be containing max of item within the selected transaction
Posted
Updated 3-Jun-14 2:52am
v2
Comments
Sprint89 30-May-14 5:24am    
if X = 7, why not

20 3 abc123 3
22 4 abc123 4
anshulpandey007 3-Jun-14 8:53am    
Hi,
I've update the note in the above question.
*Note: Atleast one should be containing max of item within the selected transactions

1 solution

use cursor or WITH clause..it can be solve the minimum row problem..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900