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

how to control the amount of free space in your index pages? : Sql server database administration

1086


What are the advantages of partitioning?

1178


Explain external key management in sql server 2008

937


If any stored procedure is encrypted, then can we see its definition in activity monitor?

1043


How to use order by with union operators in ms sql server?

1065


what is the difference in login security modes between v6.5 and 7.0? : Sql server database administration

1175


How do I edit a stored procedure in sql server?

971


How to verify a login name with sqlcmd tool?

1265


Which language is supported by sql server?

1066


What is cdc in sql server?

1046


What is difference between oltp and olap?

1093


What are the methods used to protect against sql injection attack?

1119


How do I install sql server?

937


Why do you need a sql server?

1171


how many type of indexing in database?

1021