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 |
|
barrett777
Starting Member
4 Posts |
Posted - 2011-01-28 : 09:05:00
|
| Hi everyone,I'm very new to SQL programming. I have a table somewhat like this:Date | Address# | Street Name | Amount of ErrorsWhat I want to do is list the 10 streets with the most errors for all time, in desc order.So basically I need to add together the amount of errors for each day for each unique address# and street.For example, these entries:Date | A# | Street N. | Errors1/25 | 5 | S Oakdale | 31/26 | 5 | S Oakdale | 51/25 | 10 | S Oakdale | 51/26 | 10 | S Oakdale | 81/27 | 10 | S Oakdale | 2Would return something like this:A# | Street N. | Errors10 | S Oakdale | 155 | S Oakdale | 5Hopefully that makes sense. I would also greatly appreciate help on how to do the same, but only counting errors over the last week.Thanks for your time,Ben |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-01-28 : 09:09:44
|
select [Address#],[Street N.], sum(Errors) as Errorsfrom your_tablegroup by [Street N.],[Address#]and btw. Errors for "5|S Oakdale|" will give 8 and not 5 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-29 : 11:12:56
|
| your explanation and output doesnt match. you're telling you want total for a day but in output you're doing summation irrespective of day as all your dates are different------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
barrett777
Starting Member
4 Posts |
Posted - 2011-01-30 : 19:44:35
|
| webfred got the idea, thanks so much :) |
 |
|
|
|
|
|