根据另一列中所需的总和值从表格中获取最小行数。 [英] To get the minimum number of rows from a tabel based on the desired sum value in another column.
问题描述
示例表格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 br />
16 1 pqr234 8
17 1 lmn333 4
21 2 lmn333 8
19 3 lmn333 4
假设X = 7(指定LOT所需的项目总数= abc123)
所需输出:
Sno ID LOT_ID ITEM_NUM
14 1 abc123 2
18 2 abc123 5
*注意:Atleast one应该包含所选事务中的最大项目
使用游标或WITH子句..可以解决最小行问题..
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
use cursor or WITH clause..it can be solve the minimum row problem..
这篇关于根据另一列中所需的总和值从表格中获取最小行数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!