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 |
|
syncode17
Starting Member
1 Post |
Posted - 2010-03-25 : 19:11:51
|
| Is there a way or code in SQL that i can add all repeating records in my database?for exampleSerialCode itemcode ItemName quantityS001 A100 Pen 10S002 A100 Pen 20S003 A100 Pen 30and i need the output ofitemcode itemname quantityA100 Pen 30(:>,<:)syncode17 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-25 : 19:44:11
|
yes. it is SUM() with GROUP BYselect itemcode, itemname, sum(quantity)from yourtablegroup by itemcode, itemname KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-03-26 : 02:08:57
|
quote: Originally posted by khtan yes. it is SUM() with GROUP BYselect itemcode, itemname, sum(quantity)from yourtablegroup by SerialCode, itemcode, itemname KH[spoiler]Time is always against us[/spoiler]
As per the required output query should be like above see the red part in the query.Vaibhav T |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-26 : 02:13:54
|
quote: Originally posted by syncode17 Is there a way or code in SQL that i can add all repeating records in my database?for exampleSerialCode itemcode ItemName quantityS001 A100 Pen 10S002 A100 Pen 20S003 A100 Pen 30and i need the output ofitemcode itemname quantityA100 Pen 30(:>,<:)syncode17
you wanted the record of A100 with the highest quantity ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-03-26 : 02:42:44
|
| Yes Khtan this information is must because from the post its not clear to which partition he is calling repeating records as per the sample data nothing is repeating even we remove the quantity.Vaibhav T |
 |
|
|
|
|
|
|
|