I have one column table that has some items in it say department name such as IT, IT, Sale, IT, Market, Sale, Market etc.
How can I add another column that count each department name in the following way. Basically, each item will have its own count.
name added column
EDIT: Per your request I added answer for SQL Server.
SELECT name, ROW_NUMBER() OVER (PARTITION BY Name ORDER BY Name) As AddedColumn FROM YourTable
SELECT @row_number:=CASE WHEN @name = name THEN @row_number + 1 ELSE 1 END AS num, @name:=name as name FROM YourTable ORDER BY name;