Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hiis there a way to use a StarsWith when u use the group by statement exTB1 code name1 one11 two111 three112 four2 five21 six211 sevenI want to group all records that star with '2' and '1'please help me
sodeep
Master Smack Fu Yak Hacker
7174 Posts
Posted - 2009-02-12 : 17:35:05
Yes,
Select Left(code,1)as code,Count(Name) NameCountfrom TableGroup by Left(code,1)Order by code
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-02-12 : 20:46:11
[code]Select substring(code,1,1)as code,Count(*) Cnt,MAX(Name),MIN(Name),...from TableGroup by substring(code,1,1)Order by code[/code]