Click here to Skip to main content
15,894,195 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

You can use the count function with the group by function to get these results

SQL
select veh_no,
       count(dist) as Distance
from   -- TableName
group by veh_no
 
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