Where5 1206. Sum of positive ou get an array of numbers, return the sum of all of the positives ones. Example [1,-4,7,12] => 1 + 7 + 12 = 20 Note: if there is nothing to sum, the sum is default to 0. Solution: int positiveSum(List arr) { int result = 0; for (int a in arr) { if (a > 0) { result += a; } } return result; } int positiveSum(List arr) { return arr.where((l) => l > 0).fold(0, (p, c) => p + c); } import "dart:math".. 2022. 12. 6. 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. 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. SQL Basics: Simple JOIN For this challenge you need to create a simple SELECT statement that will return all columns from the products table, and join to the companies table so that you can return the company name. products table schema id name isbn company_id price companies table schema id name You should return all product fields as well as the company name as "company_name". NOTE: Your solution should use pure SQL... 2022. 5. 23. SQL Basics: Simple WHERE and ORDER BY For this challenge you need to create a simple SELECT statement that will return all columns from the people table WHERE their age is over 50 people table schema id name age You should return all people fields where their age is over 50 and order by the age descending NOTE: Your solution should use pure SQL. Ruby is used within the test cases to do the actual testing. Solution: SELECT * FROM peo.. 2022. 5. 12. 이전 1 다음