본문 바로가기
728x90
반응형

DB/SQL20

Type of Triangle Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table: Equilateral: It's a triangle with 3 sides of equal length. 정삼각형 Isosceles: It's a triangle with 2 sides of equal length. 이등변 삼각형 Scalene: It's a triangle with 3 sides of differing lengths. 그냥 삼각형 Not A Triangle: The given valu.. 2020. 6. 19.
Employee Salaries 문제 : Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than 2000 per month who have been employees for less than months. Sort your result by ascending employee_id. SELECT name FROM Employee WHERE months 2000 ORDER BY employee_id asc; Rose Patrick Lisa Amy Pamela Jennifer Julia Kevin Paul Donna Michell.. 2020. 6. 19.
Employee Names 문제 : Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order. SELECT name FROM Employee ORDER BY name asc; 2020. 6. 19.
Higher Than 75 Marks 문제 : Query the Name of any student in STUDENTS who scored higher than Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID. SELECT Name FROM STUDENTS WHERE Marks > 75 ORDER BY RIGHT(NAME, 3), ID ASC; Stuart Kristeen Christene Amina Aamina.. 2020. 6. 19.
HackerRank_16. Weather Observation Station 10 문제 : Query the list of CITY names from STATION that do not end with vowels. Your result cannot contain duplicates. SELECT distinct CITY FROM STATION WHERE SUBSTR(CITY, -1, 1) NOT IN ('a', 'e', 'i', 'o', 'u'); Kissee Mills Loma Mar Sandy Hook Tipton Arlington Turner Slidell Negreet Chignik Lagoon Hanna City Albany Monument Manchester Prescott Graettinger Sturgis Highwood Bowdon Tyler Watkins Repu.. 2020. 6. 12.
HackerRank_15. Weather Observation Station 9 문제 : Query the list of CITY names from STATION that do not start with vowels. Your result cannot contain duplicates. SELECT distinct CITY FROM STATION WHERE SUBSTR(CITY, 1, 1) NOT IN ('a', 'e', 'i', 'o', 'u'); Kissee Mills Loma Mar Sandy Hook Tipton Turner Slidell Negreet Glencoe Chelsea Chignik Lagoon Pelahatchie Hanna City Dorrance Monument Manchester Prescott Graettinger Cahone Sturgis Highwo.. 2020. 6. 11.
HackerRank_14. Weather Observation Station 8 문제 : Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last characters. Your result cannot contain duplicates. SELECT distinct CITY FROM STATION WHERE SUBSTR(CITY, 1, 1) IN ('a', 'e', 'i', 'o', 'u') AND SUBSTR(CITY, -1, 1) IN ('a', 'e', 'i', 'o', 'u'); Upperco Aguanga East China East Irvine Amo Eleele Oconee Amazonia Aliso Viejo Anderso.. 2020. 6. 11.
HackerRank_13. Weather Observation Station 7 문제 : Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates. SUBSTR을 사용할 때 start의 위치를 -1로 지정해주었다. ( python의 list[-1] 느낌 ! ) SELECT distinct CITY FROM STATION WHERE SUBSTR(CITY, -1, 1) IN ('a', 'e', 'i', 'o', 'u'); Glencoe Chelsea Pelahatchie Dorrance Cahone Upperco Waipahu Millville Aguanga Morenci South El Monte Gustine Delano Westpha.. 2020. 6. 11.
HackerRank_12. Weather Observation Station 6 문제 : Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates. city의 첫번째 문자만 가져오기 위해서 SUBSTR 함수를 사용하자. SUBSTR(str, pos, len) 로 사용할 수 있다. MySQL : SUBSTR(), SUBSTRING() Oracle : SUBSTR() SQL Server : SUBSTRING() SELECT distinct CITY FROM STATION WHERE SUBSTR(CITY, 1, 1) IN ('a', 'e', 'i', 'o', 'u'); Arlington Albany Upperco Agua.. 2020. 6. 11.
HackerRank_11. Weather Observation Station 5 문제 : Query the two cities in STATION with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically. SELECT CITY, CHAR_LENGTH(CITY) FROM STATION ORDER BY CHAR_LENGTH(CITY) ASC, CITY ASC LIMIT 1; SELECT CITY, CHAR_LENGTH(CITY) FRO.. 2020. 6. 11.
728x90
반응형