我有一个包含几十个字段的表,其中18个是具有不同整数值的字段。我想为给定记录的五个具有最大值的字段提取字段名和相应的值。我将使用下表作为示例,其中我只想查询给定记录的两个最大值。
Name, FigureA, FigureB, FigureC
John, 40, 73, 81
Luke, 35, 21, 65
我想为约翰归还以下物品:
FigureB, 73
FigureC, 81
我已经走了这么远:
sSQL = "Select t.* " & _
"From (Select 'A' as [FigureA], FigureA " & _
"From Table) as t " & _
"Union All " & _
"Select t.* " & _
"From (Select 'B' as [FigureB], FigureB " & _
"From Table) as t " & _
"Union All " & _
"Select t.* " & _
"From (Select 'C' as [FigureC], FigureC " & _
"From Table) as t"
1条答案
按热度按时间bakd9h0s1#
在ms-access中,这可能是最简单的
union all
:某些版本的ms access不支持
union all
在from
条款。该组件可能需要一个视图。