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 |
|
PingTheServer
Starting Member
28 Posts |
Posted - 2011-04-29 : 11:54:09
|
| I am trying to group by distinct address with the first word of the name1 field matching.<code>Select COUNT (DISTINCT address)FROM May</code>Where name1...and i dont know how to trim and compare it with that grouping. Any advice is welcome. Thx. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-29 : 11:58:59
|
| Not sue what you want but maybe - and does name1 always have a space in it?Select left(name1,charindex(' ',name1), COUNT (DISTINCT address)FROM Maygroup by left(name1,charindex(' ',name1)==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
PingTheServer
Starting Member
28 Posts |
Posted - 2011-04-29 : 12:19:15
|
| name1 does always have a space, but i cant get that code to work. It doesnt like the 'left' statement. |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-29 : 13:07:31
|
| there's a missing clase bracketSelect left(name1,charindex(' ',name1)), COUNT (DISTINCT address)FROM Maygroup by left(name1,charindex(' ',name1))==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|