Else5 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: Simple table totaling. For this challenge you need to create a simple query to display each unique clan with their total points and ranked by their total points. people table schema name points clan You should then return a table that resembles below select on rank clan total_points total_people The query must rank each clan by their total_points, you must return each unqiue clan and if there is no clan name (i.e. it'.. 2022. 6. 18. 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. Coding Meetup #5 - Higher-Order Functions Series - Prepare the count of languages You will be given an array of objects (associative arrays in PHP, table in COBOL) representing data about developers who have signed up to attend the next coding meetup that you are organising. Your task is to return an object (associative array in PHP, table in COBOL) which includes the count of each coding language represented at the meetup. For example, given the following input array: list1 .. 2022. 5. 8. 이전 1 다음