End4 SQL Basics - Monsters using CASE You have access to two tables named top_half and bottom_half, as follows: top_half schema id heads arms bottom_half schema id legs tails You must return a table with the format as follows: output schema id heads legs arms tails species The IDs on the tables match to make a full monster. For heads, arms, legs and tails you need to draw in the data from each table. For the species, if the monster .. 2022. 7. 12. 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. SQL Basics: Create a FUNCTION For this challenge you need to create a basic Increment function which Increments on the age field of the peoples table. The function should be called increment, it needs to take 1 integer and increment that number by 1. You may query the people table while testing but the query must only contain the function on your final submit. important: you must remove all comments when submitting the kata... 2022. 6. 15. Even or Odd SQL Notes: You will be given a table, numbers, with one column number. Return a table with a column is_even containing "Even" or "Odd" depending on number column values. numbers table schema number INT output table schema is_even STRING Solution: SELECT CASE WHEN number%2=0 THEN 'Even' ELSE 'Odd' END AS is_even FROM numbers In psql, 'if' is 'case when ~ then ~ else ~'. 2022. 5. 19. 이전 1 다음