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:
DECLARE @TMP TABLE(CODE INT)
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 http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp Madhivanan Failing to plan is Planning to fail
You ORDER BY clause to get the correct order. Mohammed U.
]]>