CREATE PROCEDURE placesOfInterestPairs() BEGIN SELECT place1, place2 FROM (SELECT sights.name AS place1, sights2.name AS place2, SQRT(POW(sights.x - sights2.x, 2) + POW(sights.y - sights2.y, 2)) AS distance FROM sights, sights AS sights2 WHERE sights.name < sights2.name) AS t WHERE distance < 5 ORDER BY place1, place2; END
25 February 2018
placesOfInterestPairs
My solution:
Labels:
Arcade,
CodeSignal,
Databases,
JOIN Us at the Table!,
MySQL
userCountries
My solution:
CREATE PROCEDURE userCountries() BEGIN SELECT id, country FROM users, cities WHERE users.city = cities.city UNION SELECT DISTINCT id, "unknown" AS country FROM users, cities WHERE users.city NOT IN (SELECT city FROM cities) ORDER BY id; END
Labels:
Arcade,
CodeSignal,
Databases,
JOIN Us at the Table!,
MySQL
scholarshipsDistribution
My solution:
CREATE PROCEDURE scholarshipsDistribution() BEGIN SELECT candidate_id AS student_id FROM candidates WHERE candidate_id NOT IN (SELECT DISTINCT candidate_id AS id FROM candidates, detentions WHERE candidate_id = student_id ORDER BY candidate_id); END
Labels:
Arcade,
CodeSignal,
Databases,
JOIN Us at the Table!,
MySQL
Subscribe to:
Posts (Atom)