ascending order<\/em>, and output them in the following format:<\/li><\/ol>\n\n\n\nThere are a total of [occupation_count] [occupation]s.<\/code><\/pre>\n\n\n\nwhere [occupation_count]<\/code> is the number of occurrences of an occupation in OCCUPATIONS<\/strong> and [occupation]<\/code> is the lowercase<\/em> occupation name. If more than one Occupation<\/em> has the same [occupation_count]<\/code>, they should be ordered alphabetically.<\/p>\n\n\n\nNote:<\/strong> There will be at least two entries in the table for each type of occupation.<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nColumn<\/th> | Type<\/th><\/tr><\/thead> |
---|
Name<\/em><\/td>String<\/em><\/td><\/tr>Occupation<\/em><\/td>String<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n The OCCUPATIONS<\/strong> table is described as follows: <\/p>\n\n\n\nOccupation<\/em> will only contain one of the following values: Doctor<\/strong>, Professor<\/strong>, Singer<\/strong> or Actor<\/strong>.<\/p>\n\n\n\nSample Input<\/strong><\/p>\n\n\n\nAn OCCUPATIONS<\/strong> table that contains the following records:<\/p>\n\n\n\nName<\/em><\/th>Occupation<\/em><\/th><\/tr><\/thead>Samantha<\/em><\/td>Doctor<\/em><\/td><\/tr>Julia<\/em><\/td>Actor<\/em><\/td><\/tr>Maria<\/em><\/td>Actor<\/em><\/td><\/tr>Meera<\/em><\/td>Singer<\/td><\/tr> | Ashley<\/em><\/td>Professor<\/em><\/td><\/tr>Ketty<\/em><\/td>Professor<\/em><\/td><\/tr>Christeen<\/em><\/td>Professor<\/em><\/td><\/tr>Jane<\/em><\/td>Actor<\/em><\/td><\/tr>Jenny<\/em><\/td>Doctor<\/em><\/td><\/tr>Priya<\/em><\/td>Singer<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n Sample Output<\/strong><\/p>\n\n\n\nAshely(P)\nChristeen(P)\nJane(A)\nJenny(D)\nJulia(A)\nKetty(P)\nMaria(A)\nMeera(S)\nPriya(S)\nSamantha(D)\nThere are a total of 2 doctors.\nThere are a total of 2 singers.\nThere are a total of 3 actors.\nThere are a total of 3 professors.<\/code><\/pre>\n\n\n\nExplanation<\/strong><\/p>\n\n\n\nThe results of the first query are formatted to the problem description’s specifications. The results of the second query are ascendingly ordered first by number of names corresponding to each profession (2 <= 2 <= 3 <= 3<\/strong>), and then alphabetically by profession (doctor<\/em> <= singer<\/em><\/strong>, and actor <= professor<\/em><\/strong>).<\/p>\n\n\n\n<\/span>Solution – The PADS in SQL<\/strong><\/span><\/h2>\n\n\n\n<\/span>MySQL<\/strong><\/span><\/h3>\n\n\n\nSELECT concat(NAME,concat(\"(\",concat(substr(OCCUPATION,1,1),\")\"))) FROM OCCUPATIONS ORDER BY NAME ASC;\nSELECT \"There are a total of \", count(OCCUPATION), concat(lower(occupation),\"s.\") FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY count(OCCUPATION), OCCUPATION ASC<\/pre>\n\n\n\n
| | | | | | | | | | | | | | | | | | | | |
---|
| | | |