Hi all,

I need query help for below senorio, could you please help
me.

TableName = City
CITYID ContinuationID CITYNAME
1 1 SAN
1 2 DIEGO
2 1 SAN
2 2 FRANCISCO
3 1 CHICAGO
4 1 NEW
4 2 YORK
4 3 CITY

Could you please help me to write a generalized SQL that
returns results as given below in the

Query result
CITYID NAME1 NAME2 NAME3 NAME4 NAME5
1 SAN DIEGO
2 SAN FRANCISCO
3 CHICAGO
4 NEW YORK CITY

Answer Posted / das

select cityid,group_concat(cityname) as city from city group by cityid;

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why use “pivot” in sql server?

779


difference between Clustered index and non clustered index ?

742


What is the difference between dbcc indexdefrag and dbcc reindex?

708


Can a function call a stored procedure in sql server?

702


How can sql server instances be hidden? : sql server security

747






What is blocking and how would you troubleshoot it? : sql server database administration

765


What is collation sensitivity?

717


What are the advantages of paper records?

723


What do you understand by replication in sql server?

749


What does the update command do?

786


What encryption security is available in sql azure?

91


What do you need to connect php to sql server?

757


What is the boxing and unboxing concept in .net?

710


What is the new security features added in sql server 2014? : sql server security

754


What is log in sql server?

761