Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
crugerenator
Posting Yak Master
126 Posts |
Posted - 2008-07-03 : 11:11:11
|
| I need to sum pieces of an order to get the order total. This total needs to be displayed on my site and included in an xml doc. Here's an example of what I have...-Order-orderID -pkstoreID -OrderItem-orderItemID -pkorderID -fkorderItemTypeID -fkquantity-OrderItemType-orderItemTypeID - pkdollarValueisCoinBasically, I need to sum dollarValue and isCoin for each orderID. How do I do this? Also, should I make this a stored procedure instead of doing the calculations on my site everytime? |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2008-07-03 : 14:38:23
|
| something likeSELECT o.orderid,SUM(oit.iscoin + oit.DollarValue)FROM order oINNER JOIN orderitem oiON o.orderid = oi.orderidINNER JOIN orderitemtype oitON oi.orderitemtypeid = oit.orderitemtypeidGROUP BY o.orderJim |
 |
|
|
|
|
|