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;
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', 두 변의 길이가 같다면 'Isosceles', 아니면 'Scalene' 출력,
삼각형이 아니면 'Not A Triangle' 출력
SELECT CASE WHEN A + B > C AND B + C > A AND A + C > B THEN
CASE WHEN A = B AND B = C THEN 'Equilateral'
WHEN A = B OR B = C OR C = A THEN 'Isosceles'
ELSE 'Scalene'
END
ELSE 'Not A Triangle'
END
FROM TRIANGLES;
There are a total of [occupation_count] [occupation]s.
Sample Output
Ashely(P)
Christeen(P)
Jane(A)
Jenny(D)
Julia(A)
Ketty(P)
Maria(A)
Meera(S)
Priya(S)
Samantha(D)
There are a total of 2 doctors.
There are a total of 2 singers.
There are a total of 3 actors.
There are a total of 3 professors.
SELECT CONCAT(NAME, '(', LEFT(OCCUPATION, 1), ')')
FROM OCCUPATIONS
ORDER BY 1;
SELECT CONCAT('There are a total of ', COUNT(OCCUPATION), ' ', LOWER(OCCUPATION), 's.')
FROM OCCUPATIONS
GROUP BY OCCUPATION
ORDER BY 1;
SELECT SALARY * MONTHS, COUNT(*)
FROM EMPLOYEE
GROUP BY 1
ORDER BY 1 DESC
LIMIT 1