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 |
|
Vanhail
Starting Member
1 Post |
Posted - 2010-03-29 : 13:25:55
|
| So I have a SELECT query that returns an account ID and all the relevant fields I need about that account. My problem is I end up with more than one record per account. These aren't exactly duplicates, there is a reason I get more than on row, I should be. But I want to be able to refine my results to only one row per unqiue account. It's seem more challenging than it should be, but there is really no criteria I want to use to filter for one row per account. I just only care about getting one row per account back because the data I am after is the same on the rest of the rows.I'm able to pull the distinct list of accounts, but due to how distinct works I can only pull the distinct account, not with the rest of the useful data.Anyone know of a method to get this accomplished? Thanks, |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-03-29 : 13:32:35
|
| Without knowing your data one simple way is to use the ROW_NUMBER() function or, if most the data is the same, you could use MIN/MAX aggregate functions to aggregate down the results to a single row per Account ID. |
 |
|
|
|
|
|