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 |
|
ddobbertin
Yak Posting Veteran
51 Posts |
Posted - 2006-11-21 : 23:43:07
|
| I am trying to run a query to get a count of similar items. For instance if my sample records are:locationa_123a_123_4b_123b_123_1b_123_2b_456_1b_456_2table name:recordssample query:select location, count(*) from records group by locationI would like to have the query return:a_123 - 2b_123 - 3b_456 - 2 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-21 : 23:44:36
|
[code]select left(location, 5), count(*)from recordsgroup by left(location, 5)[/code] KH |
 |
|
|
ddobbertin
Yak Posting Veteran
51 Posts |
Posted - 2006-11-21 : 23:48:35
|
| Geeze....I am such a bonehead. I should have realized that. I must be thinking of the 4 day weekend already too much. Thanks for the quick response. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-21 : 23:49:53
|
I would too if i had 4 days weekend ahead  KH |
 |
|
|
|
|
|