알고리즘/codefightsDB

21>travelDiary

Diademata 2019. 3. 25. 13:14
반응형

You are an avid traveler and you've visited so many countries that when people ask you where you've been, you can't even remember all of them! Luckily, every time you travel somewhere you write down the trip information in your diary. Now you want to get a list of all the different countries that you have visited using the information in your diary.


The diary is represented as a table diary, which has the following columns:


id: the unique ID of the trip;

travel_date: the date the trip began;

country: the country to which you traveled.

Given this diary table, create a semicolon-separated list of all the distinct countries you've visited, sorted lexicographically, and put the list in a table that has a single countries column.


code>>


/*Please add ; after each select statement*/

CREATE PROCEDURE travelDiary()

BEGIN

SELECT group_concat(DISTINCT country order by country SEPARATOR ';') as countries from diary;

END

반응형

'알고리즘 > codefightsDB' 카테고리의 다른 글

23>marketReport  (0) 2019.03.25
22>soccerPlayers  (0) 2019.03.25
20>movieDirectors  (0) 2019.03.25
19>usersByContinent  (0) 2019.03.25
18>itemCounts  (0) 2019.03.13