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 is "scheduled jobs" or "scheduled tasks"?
How to update values in a table with update statements in ms sql server?
How is sql server used?
What happens if null values are involved in datetime operations?
Does sql server use t sql?
What is the purpose of linked server configuration in sql server?
Explain the concepts and capabilities of sql server?
What are the pros and cons of putting a scalar function in a queries select list or in the where clause?
Explain the difference between function and stored procedure?
What is transaction server explicit transaction?
Explain about link server in sql server?
What is a partition key?
What are the differences between having and where clause.
Differentiate between ms sql server reporting services vs crystal reports?
What is the difference between for auto and for nested?