Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / praveen singh

create table #temp1(id int)

insert into #temp1 values(4)


declare @str nvarchar(500)
select @str=''
select @str =@str+ id from (select cast(id as varchar) +'('+
cast(count(id) as varchar(22))+ ')' id from #temp1 group
by id) t
select @str


output will be :1(5)2(1)3(2)4(1)

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a join in sql? What are the types of joins?

1108


What is an execution plan?

1155


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

1039


what is a transaction and what are acid properties? : Sql server database administration

1026


What will be the value of @@fetch_status if a row that was a part of the cursor resultset has been deleted from the database after the time the stored procedure that opened the cursor was executed?

1142


How do I start sql server?

978


Explain different types of self contained sub query?

1046


How you can change the database name in SQL SERVER?

1194


How do I change my passwords (database, LDAP, and so on) without causing an outage?

1069


Relational calculus is what type of language?

1038


How to create a view with data from multiple tables?

1014


What is abstracting periodical?

948


What is rtm version in sql server?

1057


Explain about remote stored procedure?

1012


What is a not null constraint?

1035