Identical rows | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Identical rows

Hello, How can I write a query which returns the number of records where a code is identical Fe Code Number
1001 2
1002 1
1003 2 Thanks
check this:
insert @tmp
select 1001 union all
select 1001 union all
select 1002 select code,count(*) as number from @tmp
group by code
You need to Learn SQL Madhivanan Failing to plan is Planning to fail
You ORDER BY clause to get the correct order. Mohammed U.