I have the following table and data in SQL Server 2005:
create table LogEntries (
ID int identity,
LogEntry varchar(100)
)
insert into LogEntries values ('beans')
insert into LogEntries values ('beans')
insert into LogEntries values ('beans')
insert into LogEntries values ('cabbage')
insert into LogEntries values ('cabbage')
insert into LogEntries values ('beans')
insert into LogEntries values ('beans')
I would like to group repeated LogEntries so that I have the following results:
LogEntry EntryCount
beans 3
cabbage 2
beans 2
Can you think of any way to do this in TSQL outside of using a cursor?