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 |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-09-11 : 17:15:11
|
| Have two tables. Gbkmut, orderrebatehistoryHave 3 entries in the orderrebatehistory where I want to total the rebate amt and insert a record with the total in the gbkmut.I have the statement to get my calculation, but my trouble is when I insert the record into the gbkmut it is inserting 3 records with my total and not just one. ORHOrd_no Inv_no rebate_amt item_no 23 12 1.50 xyz 23 12 2.00 cdd 23 12 3.00 yyyI want to insert 1 record into the gbkmut with an amoutn fo 6.50. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-09-11 : 17:26:34
|
| Show us what you have so far, so we can help you with that.It'll be something like this though:INSERT INTO...SELECT ..., SUM(rebate_amt)FROM SomeTableGROUP BY ... <-- but not rebate_amtTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
pommguest99
Starting Member
16 Posts |
Posted - 2008-09-11 : 17:28:34
|
| select Ord_no, sum(rebate_amt) as Total from ORHgroup by Ord_no |
 |
|
|
|
|
|