also, the answer still correct after changing MIN to MAX but if i delete min or max, the answer is wrong. My question is what does the function MIN doing in this code. You may add any prizes that you would like to offer here. SELECT ROW_NUMBER() OVER(PARTITION BY Occupation MySQL to Share with friends: Sign Up Starts in About Please provide a short description of your contest here This will also be used as metadata. SELECT MIN(IF(Occupation = 'Doctor',Name,NULL)),MIN(IF(Occupation = 'Professor',Name,NULL)),MIN(IF(Occupation = 'Singer',Name,NULL)),MIN(IF(Occupation = 'Actor',Name,NULL)) The empty cell data for columns with less than the maximum number of names per occupation (in this case, the Professor and Actor columns) are filled with NULL values.Īfter searching and learning from internet, the correct answer for this challenge by using MYSQL: The fourth column is an alphabetically ordered list of Actor names. The third column is an alphabetically ordered list of Singer names. The second column is an alphabetically ordered list of Professor names. The first column is an alphabetically ordered list of Doctor names. Another interesting query, with very unique criteria that you need to pay attention to. Please read our cookie policy for more information about how we use cookies. We use cookies to ensure you have the best browsing experience on our website. Steps to Answer Database Questions Here is a quick video to get you started with the Answering Database programming Questions workflow. Join over 16 million developers in solving code challenges on HackerRank, one of the best ways to prepare for programming interviews. Occupation will only contain one of the following values: Doctor, Professor, Singer or Actor. Hackerrank SQL Advanced Select Occupations Solution. The HackerRank Test interface has an in-built database query editor and supports programming in Microsoft SQL, MySQL, Oracle, or DB2 databases. The OCCUPATIONS table is described as follows: Intro Hacker Rank MySQL Solved Questions (2020) - Part (1) Anshuman Biswal 1.04K subscribers 9.9K views 2 years ago Hacker Rank MySQL 2020 Solved Problems Problem Statement - 1. Note: Print NULL when there are no more names corresponding to an occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively. Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |