问题描述
Hello Everybody,
如何从列表中选择值
示例:
veh_no dist
-------------------------------------------- -
AP3456 45
KN6344 56
KN6344 78
TN3851 108
对于上面的例子,如何选择基于三个veh_no的距离总和,我们无法定义veh_no ='AP3456'和'KN6344'和'TN3851'......可以输入车辆号码
结果集
dist
------------
134
108
Hello Everybody,
How to select values from List
EXAMPLE:
veh_no dist
----------------------------------------------
AP3456 45
KN6344 56
KN6344 78
TN3851 108
For the above example, how to select sum of distance based on three veh_no where we can't define veh_no='AP3456' and'KN6344' and 'TN3851'... vehicle number list may be input
Resultset
dist
------------
45
134
108
推荐答案
select veh_no,
count(dist) as Distance
from -- TableName
group by veh_no
这篇关于如何在sql server 2008中选择列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!