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
‘Order by’ is not allowed in a view how can you sort information from a view?
Difference between connected and disconnected database in .net with sql server?
What are the different types of collation sensitivity?
How to find index size for each index on table?
What is blocking and how would you troubleshoot it? : sql server database administration
How are the exceptions handled in sql server programming?
What are different types of statement?
What is sql view?
How do you create an execution plan?
Describe triggers features and limitations?
Explain what are the events recorded in a transaction log?
How to change parameter value inside the report?
What are statistics?
Why use identity in sql server?
How to insert multiple rows with one insert statement in ms sql server?