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
How to sort query output in descending order in ms sql server?
What is cdc in sql server?
How to add the custom code in Report?
What is partition in sql server?
Give main differences between "Truncate" and "Delete".
How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?
How to populate a table in sql server?
Why use “pivot” in sql server?
Can you create a logon trigger in sql server 2005 express edition?
What is factless fact table? : sql server analysis services, ssas
How to check if a table is being used in sql server?
what are the three command line utilities and what are their primary functions?
Why we should not use triggers?
1. Tell me your daily activities 2. If sql server installation fails at time installation what will do 3. Where does the sql server installation log details are stored 4. After the installation what will you do for memory configuration 5. What is the difference between SQL max maximum memory and AWE memory 6. How will you configure AWE memory 7. How will setup an email alert for the backup job 8. After the SQL installation what are the jobs will you configure 9. What does –g mean in the sql startup parameter 10. What is the difference between Bulked log and Full recovery model 11. What is the difference between mirroring and log shipping 12. What are the steps to be followed before in-place up gradation 13. After installing the patch the sql server does not start and application team tells to rollback the changes .In this scenario what will you do
How to modify an existing stored procedure in ms sql server?