Created
June 21, 2020 17:13
-
-
Save Mandonglawrence/db82b3247b86d1beea021e676be10565 to your computer and use it in GitHub Desktop.
SQL submission
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1) percentage of global sales in North America: | |
SELECT (SUM(NA_Sales) | |
/(sum(na_sales)+sum(EU_Sales)+sum(JP_Sales)+sum(Other_Sales)))*100 | |
FROM consoleGames | |
(2) SELECT Name FROM ConsoleGames | |
ORDER BY Platform ASC, Year DESC | |
(3) first four letter of console game publisher: | |
SELECT substr(Publisher,1,4) FROM ConsoleGames | |
(5) platforms ordered by longevity in ascending | |
SELECT Platform FROM ConsoleDates | |
ORDER BY FirstRetailAvailability DESC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
complaints sent and received on the same date =>28737 | |
SELECT field1, COUNT(field1) FROM ConsumerComplaints WHERE field1=field14; | |
complaints received in New York==> 4413 | |
SELECT field9, COUNT(field9) FROM ConsumerComplaints WHERE field9="NY"; | |
complaints received in New York and califonia ==>13668 | |
SELECT field9, COUNT(field9) FROM ConsumerComplaints WHERE field9="NY" OR field9 = "CA"; | |
product with the word "Credit" ==>18564 | |
SELECT field2, COUNT(field2) FROM ConsumerComplaints WHERE field2 LIKE "%Credit%"; | |
issues with the word "Late" ==>312 | |
SELECT field4, COUNT(field4) FROM ConsumerComplaints WHERE field4 LIKE "%Late%"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1) sql: | |
SELECT title FROM movies WHERE year ="2018"; | |
(2) sql: | |
SELECT birth FROM people WHERE name ="Emma Stone"; | |
(3) sql: | |
SELECT title FROM movies WHERE year >= "2018" ORDER BY title; | |
(4) sql: | |
SELECT title,COUNT(title) FROM movies JOIN ratings ON | |
movies.id=ratings.movie_id WHERE rating = 10.0; | |
(5) sql: | |
SELECT title, year FROM movies | |
WHERE title LIKE "%Harry Potter%" ORDER BY year ASC; | |
(6) sql: | |
SELECT rating, AVG(rating) FROM ratings JOIN | |
movies On ratings.movie_id =movies.id WHERE year = 2012; | |
(7) sql: | |
SELECT title,rating FROM movies JOIN ratings ON | |
movies.id=ratings.movie_id ORDER BY 2 DESC,1; | |
OR | |
SELECT title,rating FROM movies JOIN ratings ON | |
movies.id=ratings.movie_id ORDER BY rating DESC,title; | |
(8) sql: | |
SELECT name FROM people JOIN stars ON people.id=stars.person_id | |
JOIN movies ON stars.movie_id=movies.id WHERE title = "Toy Story"; | |
(9) sql: | |
SELECT DISTINCT name FROM people JOIN stars ON people.id=stars.person_id | |
JOIN movies ON stars.movie_id=movies.id WHERE year = "2004" ORDER BY birth; | |
(10) sql: | |
SELECT DISTINCT name FROM people JOIN directors ON people.id=directors.person_id | |
JOIN movies ON directors.movie_id=movies.id | |
JOIN ratings ON movies.id=ratings.movie_id WHERE rating >= 9.0; | |
(11) sql: | |
SELECT DISTINCT title FROM people JOIN stars ON people.id=stars.person_id | |
JOIN movies ON stars.movie_id=movies.id | |
JOIN ratings ON movies.id=ratings.movie_id WHERE name ="Chadwick Boseman" ORDER BY rating DESC LIMIT 5; | |
(12) sql: | |
SELECT title FROM | |
people JOIN stars ON people.id=stars.person_id | |
JOIN movies ON stars.movie_id=movies.id | |
WHERE name = "Helena Bonham Carter" AND | |
movie_id IN (SELECT movie_id FROM people JOIN stars | |
ON stars.person_id= people.id | |
WHERE name = "Helena Bonham Carter"); | |
(13) sql: | |
SELECT name FROM people | |
JOIN stars ON people.id=stars.person_id WHERE movie_id | |
IN | |
(SELECT movie_id FROM people | |
JOIN stars ON people.id=stars.person_id | |
JOIN movies ON stars.movie_id=movies.id | |
WHERE name="Kevin Bacon" AND birth =1958) AND name != "Kevin Bacon"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1) information on pet names and owners names side by side: | |
SELECT "p9-pets".Name,"p9-owners".name FROM "p9-pets" | |
JOIN "p9-owners" on "p9-pets".ownerid="p9-owners".ownerid | |
(2) Match up all procedures performed to their descriptions: | |
SELECT ProcedureType,Description FROM "p9-proceduresdetails" | |
(3) Most popular procedures and how much they cost: | |
SELECT ProcedureType,Price FROM "p9-proceduresdetails" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment