본문 바로가기

SQL69

SQL Basics: Truncating Given the following table 'decimals': decimals table schema id number1 number2 Return a table with a single column towardzero where the values are the result of number1 + number2 truncated towards zero. Solution: SELECT TRUNC(number1 + number2) AS towardzero FROM decimals Result: towardzero 1 2 0 2 2 1 Reference: ROUND / TRUNC / MOD 반올림과 버림 그리고 나머지값 구하기 round .round(data) : 반올림하여 정수로 변환 .round(d.. 2022. 6. 30.
Easy SQL: Counting and Grouping Given a demographics table in the following format: ** demographics table schema ** id name birthday race you need to return a table that shows a count of each race represented, ordered by the count in descending order as: ** output table schema ** race count Solution: SELECT race, COUNT(id) FROM demographics GROUP BY race ORDER BY count DESC Result: race count American Indian or Alaska Native 2.. 2022. 6. 29.
Countries Capitals for Trivia Night (SQL for Beginners #6) Your friends told you that if you keep coding on your computer, you are going to hurt your eyes. They suggested that you go with them to trivia night at the local club. Once you arrive at the club, you realize the true motive behind your friends' invitation. They know that you are a computer nerd, and they want you to query the countries table and get the answers to the trivia questions. Schema .. 2022. 6. 28.
First and last IP in a network Task Given a table where users' connections are logged, find the first and the last address of the networks they connected from. Notes Order the result by the id column There's no need to validate anything - it's okay if the user connects from a private network (You don't need the connection_time field for this task but without it the input data looks too dull) You can read more about IPv4 on Wi.. 2022. 6. 27.
SQL Basics - Trimming the Field You have access to a table of monsters as follows: monsters schema id name legs arms characteristics The monsters in the provided table have too many characteristics, they really only need one each. Your job is to trim the characteristics down so that each monster only has one. If there is only one already, provide that. If there are multiple, provide only the first one (don't leave any commas i.. 2022. 6. 26.
SQL: Disorder You are given a table numbers with just one column, number. It holds some numbers that are already ordered. You need to write a query that makes them un-ordered, as in, every possible ordering should appear equally often. Solution: SELECT * FROM numbers ORDER BY random() 2022. 6. 25.