also, the answer still correct after changing MIN to MAX but if i delete min or max, the answer is wrong. Solution-1: (MySQL Query): SET nooflines 20 + 1 SELECT REPEAT ( ' ', nooflines : nooflines -1) FROM INFORMATIONSCHEMA.TABLES NOTE: The INFORMATIONSCHEMA.TABLES view allows you to get information about all tables and views within a database. My question is what does the function MIN doing in this code. SELECT ROW_NUMBER() OVER(PARTITION BY Occupation 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. When a programmer submits a solution to a programming challenge, their submission is scored on the accuracy of their output. Occupation will only contain one of the following values: Doctor, Professor, Singer or Actor. HackerRanks programming challenges can be solved in a variety of programming languages (including Java, C++, PHP, Python, SQL, JavaScript) and span multiple computer science domains. The OCCUPATIONS table is described as follows: Star 1 Code Issues Pull requests My HackerRank solutions. 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. It may include documentation of features of MySQL versions that have not yet been released. It documents MySQL 5.7 through 5.7.44, as well as NDB Cluster releases based on version 7.5 of through 5.7.43-ndb-7.5.31, respectively. Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. MySQL 5.7 Reference Manual Including MySQL NDB Cluster 7.5 and NDB Cluster 7.6 This is the MySQL Reference Manual.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |