if we have a column (Key) in a table.
and values of that column is
Key
1
1
1
2
2
3
3
4
4
5
5
5
and we want to show the data after query..like..

1(3)
2(3)
3(2)
4(2)
5(3)
how many times a single term comes..

Answer Posted / pradip jain

select convert(varchar,key) + '('+ convert(varchar,
count(key))+')' from table_name group by key

Hanamesh, why top 20?

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the functions in sql server?

709


What is cross join in sql server joins?

801


What are the different type of replication in sql server?

739


what are the disadvantages of cursors? : Sql server database administration

688


How to handle error or exception in sql?

705






What are dml (data manipulation language) statements in ms sql server?

738


How to view existing indexes on an given table using sys.indexes?

807


What is explicit cursors?

735


What are the database objects? : SQL Server Architecture

705


How to insert multiple rows with a subquery?

724


What are the different types of data sources in ssrs?

165


What stored by the master?

718


What is the difference between nvl and nvl2?

719


What are different types of replication in sql server?

750


How can a user-defined datatype be created?

730