본문 바로가기

SQL69

SQL Basics: Simple JOIN with COUNT or this challenge you need to create a simple SELECT statement that will return all columns from the people table, and join to the toys table so that you can return the COUNT of the toys people table schema id name toys table schema id name people_id You should return all people fields as well as the toy count as "toy_count". Solution: SELECT p.id, p.name, COUNT(t.name) AS toy_count FROM people .. 2022. 7. 19.
SQL Basics: Simple HAVING For this challenge you need to create a simple HAVING statement, you want to count how many people have the same age and return the groups with 10 or more people who have that age. people table schema id name age return table schema age total_people Solution: SELECT age, COUNT(age) AS total_people FROM people GROUP BY age HAVING COUNT(age) >= 10 Result: age total_people 16 13 54 11 47 14 99 11 4.. 2022. 7. 19.
Hello SQL World! Hello SQL! Return a table with a single column named Greeting with the phrase 'hello world!' Please use Data Manipulation Language and not Data Definition Language to solve this Kata Solution: SELECT 'hello world!' AS "Greeting" The reason 'Greeting' is enclosed in double quotation marks is that uppercase letters are changed to lowercase letters unless they are enclosed in double quotation marks.. 2022. 7. 17.
GROCERY STORE: Logistic Optimisation You are the owner of the Grocery Store. All your products are in the database, that you have created after CodeWars SQL excercises!:) You have reached a conclusion that you waste to much time because you have to many different warehouse to visit each week. You have to find out how many different type of products you buy from each producer. If you take only few items from some of them you will st.. 2022. 7. 16.
SQL: Regex Replace You are given a table named repositories, format as below: ** repositories table schema ** project commits contributors address The table shows project names of major cryptocurrencies, their numbers of commits and contributors and also a random donation address ( not linked in any way :) ). Your job is to remove all numbers in the address column and replace with '!', then return a table in the f.. 2022. 7. 15.
SQL Basics: Top 10 customers by total payments amount Overview For this kata we will be using the DVD Rental database. You are working for a company that wants to reward its top 10 customers with a free gift. You have been asked to generate a simple report that returns the top 10 customers by total amount spent ordered from highest to lowest. Total number of payments has also been requested. The query should output the following columns: customer_i.. 2022. 7. 14.