전체 글823 Opposite number Very simple, given an integer or a floating-point number, find its opposite. Examples: 1: -1 14: -14 -34: 34 You will be given a table: opposite, with a column: number. Return a table with a column: res. Solution: SELECT number * -1 AS res FROM opposite Below is a method to solve uselessly and difficultly using CASE and SIGN. The 'SIGN' function tells whether the number is negative or positive w.. 2022. 6. 11. SQL with LOTR: Elven Wildcards Deep within the fair realm of Lothlórien, you have been asked to create a shortlist of candidates for a recently vacated position on the council. Of so many worthy elves, who to choose for such a lofty position? After much thought you decide to select candidates by name, which are often closely aligned to an elf's skill and temperament. Choose those with tegil appearing anywhere in their first n.. 2022. 6. 10. SQL Basics: Raise to the Power Given the following table 'decimals': decimals table schema id number1 number2 Return a table with a single column result which is the output of number1 raised to the power of number2. Solution: SELECT POWER(number1, number2) as result FROM decimals The 'POWER' function returns the value raised to the power of the first argument by the second argument. 2022. 6. 9. BASICS: Length based SELECT with LIKE You will need to create SELECT statement in conjunction with LIKE. Please list people which have first_name with at least 6 character long names table schema id first_name last_name results table schema first_name last_name Solution: SELECT first_name, last_name FROM names WHERE first_name LIKE '______%' Percent Sign (%): represents zero or more unspecified characters Under Score(_) : Represents.. 2022. 6. 8. SQL Basics: Repeat and Reverse Using our monsters table with the following schema: monsters table schema id name legs arms characteristics return the following table: ** output schema** name characteristics Where the name is the original string repeated three times (do not add any spaces), and the characteristics are the original strings in reverse (e.g. 'abc, def, ghi' becomes 'ihg ,fed ,cba'). Solution: SELECT REPEAT(name,3.. 2022. 6. 7. SQL Basics - Position You have access to a table of monsters as follows: monsters schema id name legs arms characteristics In each row, the characteristic column has a single comma. Your job is to find it using position(). You must return a table with the format as follows: output schema id name comma The comma column will contain the position of the comma within the characteristics string. Order the results by comma.. 2022. 6. 6. 이전 1 ··· 74 75 76 77 78 79 80 ··· 138 다음