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

Is sql server a database?

532


How and why use sql server?

539


What are the various editions of sql server 2017 that are available in the market?

503


What is the difference between SQL notification and SQL invalidation?

585


What is indexed view? How to create it?

595






What happens if you insert a duplicate key for the primary key column in ms sql server?

523


What is a cache in ssrs?

110


What is the dbcc command and why is it used?

569


Does group by sort data?

511


Why Master database is required?

598


What is the order in which the sql query is executed?

522


How to update multiple rows with one update statement in ms sql server?

634


Is the primary key column of a table an index in ms sql server?

538


What are “unrepeatable reads”?

738


Create and insert into temp table in sql server?

581