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
What are the differences between DDL, DML and DCL in SQL?
What do you understand by intent locks?
What is create statement?
What is the purpose of grouping data in a report?
Why we use trigger in sql server with example?
How will you go about resolving deadlocks?
What is indexed view?
What is a fill factor?
What is filestream?
What is instead of trigger sql server?
Explain the first normal form(1nf)?
What is the purpose of self join?
What is auditing in sql server?
What are the advantages of using stored procedures?
How to change a login name in ms sql server?