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 / hanamesh havale

select top 10 cast(key as varchar)
+ '(' + cast(count(key) as varchar) + ')'
from TableName
group by key


Hanamesh Havale
Influx Infotech

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why would you use sql agent?

723


What is tabulation?

551


What are the advantages of using a stored procedure?

553


What is the user of Primary key?

575


What is the purpose of a table?

511






Do you know what is raid and what are different types of raid configurations? : SQL Server Architecture

537


Explain the use of containers in ssis and also their types?

520


Is foreign key a primary key?

505


What is the difference between DATETIME2 and DATETIME?

618


What objects does the fn_my_permissions function reports on? : sql server security

550


How can we rewrite sub-queries into simple select statements or with joins?

519


What is data source document?

541


Why you need indexing? Where that is stored and what you mean by schema object? For what purpose we are using view?

489


What is the use of @@spid?

565


What is the difference between a function and a stored procedure?

555