| Author |
Topic |
|
lgarcia3
Starting Member
15 Posts |
Posted - 2011-04-18 : 17:32:21
|
| I have a table of Orders for a company (call order header). In the order header we have the number of people serve by an order. We pull information about the order along with the items sold in a especific order. Then we see in the result:OrderNumber, Served, ItemID, ItemPrice, EmployeeID1111, 5, 1, 23.50,151111, 5, 4, 3.20,152222, 2, 8, 9.00,152222, 2, 6, 12.35,153333, 1, 1, 0.50,15 We need to have only the addition of the "Served" column for this especific Employee (15), which would be 8 in this case. How do I do that?Thanks! |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-18 : 17:46:30
|
If you are asking what I think you are, then you can do it like this:SELECT EmployeeId, SUM(DISTINCT Served)FROM YourTableGROUP BY EmployeeId; But, is it possible to have two rows like this:1111, 5, 1, 23.50,151111, 7, 4, 3.20,15 If so, what would be the result you are expecting? |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-18 : 17:48:39
|
| Not sure what you are looking for but maybeselect EmployeeID, sum(Served)from(select distinct OrderNumber, Served, EmployeeID) agroup by EmployeeID==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|