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 |
|
dbillings
Starting Member
1 Post |
Posted - 2009-05-07 : 20:14:40
|
| I want to create subtotals and totals for a table based on the first two digits of an accountid. For example...account balance100001 10.00100002 20.00110001 10.00110002 5.00So I want to group a total for 100001 and 100002 for a total of 30.00 and group 110001 and 110002 for a total of 15.00. Any ideas on how I would do this? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-07 : 20:27:34
|
[code]select left(account, 2), sum(balance)from tablegroup by left(account, 2)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-08 : 10:27:07
|
| [code]select account/10000, sum(balance)from tablegroup by account/10000[/code] |
 |
|
|
|
|
|