나는 이렇게 학습한다/Algorithm & SQL405 Adults only (SQL for Beginners #1) In your application, there is a section for adults only. You need to get a list of names and ages of users from the users table, who are 18 years old or older. users table schema name age NOTE: Your solution should use pure SQL. Ruby is used within the test cases just to validate your answer. Solution: SELECT name, age FROM users WHERE age >= 18 2022. 6. 25. SQL: Padding Encryption You are given a table with the following format: ** encryption table schema ** md5 sha1 sha256 Problem is the table looks so unbalanced - the sha256 column contains much longer strings. You need to balance things up. Add '1' to the end of the md5 addresses as many times as you need to to make them the same length as those in the sha256 column. Add '0' to the beginning of the sha1 values to achie.. 2022. 6. 23. Sum of angles Find the total sum of internal angles (in degrees) in an n-sided simple polygon. N will be greater than 2. Solution: SELECT 180 * (n - 2) AS res FROM angle The sum of the interior angles of an n-gon is 180˚× (n-2). Result: res 9720 12960 10080 15660 12780 5400 16920 2022. 6. 22. SQL Basics: Up and Down Given a table of random numbers as follows: numbers table schema id number1 number2 Your job is to return table with similar structure and headings, where if the sum of a column is odd, the column shows the minimum value for that column, and when the sum is even, it shows the max value. You must use a case statement. output table schema number1 number2 Solution: SELECT CASE WHEN MOD(SUM(number1).. 2022. 6. 21. GROCERY STORE: Inventory You are the owner of the Grocery Store. All your products are in the database, that you have created after CodeWars SQL excercises!:) Today you are going to CompanyA warehouse You need to check what products are running out of stock, to know which you need buy in a CompanyA warehouse. Use SELECT to show id, name, stock from products which are only 2 or less item in the stock and are from Company.. 2022. 6. 20. Best-Selling Books (SQL for Beginners #5) You work at a book store. It's the end of the month, and you need to find out the 5 bestselling books at your store. Use a select statement to list names, authors, and number of copies sold of the 5 books which were sold most. books table schema name author copies_sold Solution: SELECT * FROM books ORDER BY copies_sold DESC LIMIT 5 Result: name author copies_sold The Unbearable Lightness of Bein.. 2022. 6. 19. 이전 1 ··· 37 38 39 40 41 42 43 ··· 68 다음