-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add solution for Basic Select domain
- Loading branch information
Showing
20 changed files
with
195 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
( | ||
SELECT | ||
city, | ||
LENGTH(city) | ||
FROM | ||
station | ||
ORDER BY | ||
LENGTH(city), | ||
city | ||
LIMIT | ||
1 | ||
) | ||
UNION | ||
( | ||
SELECT | ||
city, | ||
LENGTH(city) | ||
FROM | ||
station | ||
ORDER BY | ||
LENGTH(city) DESC, | ||
city | ||
LIMIT | ||
1 | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- USING LIKE | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
city LIKE 'a%' | ||
OR city LIKE 'e%' | ||
OR city LIKE 'i%' | ||
OR city LIKE 'O%' | ||
OR city LIKE 'u%'; | ||
|
||
-- USING REGEXP | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
city REGEXP '^[a, e, i, o, u].*'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- USING LIKE | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
city LIKE '%a' | ||
OR city LIKE '%e' | ||
OR city LIKE '%i' | ||
OR city LIKE '%o' | ||
OR city LIKE '%u'; | ||
|
||
-- USING REGEXP | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
city REGEXP '.*[a, e, i, o, u]$'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- USING REGEXP | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
city REGEXP '^[a,e,i,o,u].*[a,e,i,o,u]$'; | ||
|
||
-- USING STRING FUNCTION | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
LEFT(city, 1) IN ('a', 'e', 'i', 'o', 'u') | ||
and RIGHT(city, 1) IN ('a', 'e', 'i', 'o', 'u'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- USING REGEXP | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
city NOT REGEXP '^[a, e, i, o, u].*'; | ||
|
||
-- USING STRING FUNCTIONS | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
LEFT(city, 1) NOT IN ('a', 'e', 'i', 'o', 'u'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
RIGHT(city, 1) NOT IN ('a', 'e', 'i', 'o', 'u'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
LEFT(city, 1) NOT IN ('a', 'e', 'i', 'o', 'u') | ||
AND RIGHT(city, 1) NOT IN ('a', 'e', 'i', 'o', 'u'); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SELECT | ||
name | ||
FROM | ||
students | ||
WHERE | ||
marks > 75 | ||
ORDER BY | ||
SUBSTRING(name, -3, 3), | ||
id; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
name | ||
FROM | ||
employee | ||
ORDER BY | ||
name; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
SELECT | ||
name | ||
FROM | ||
employee | ||
WHERE | ||
(salary > 2000) | ||
AND (months < 10) | ||
ORDER BY | ||
employee_id; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT * | ||
FROM city | ||
WHERE countrycode = 'USA' | ||
AND population > 100000; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SELECT NAME | ||
FROM city | ||
WHERE countrycode = 'USA' | ||
AND population > 120000; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SELECT * | ||
FROM city; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT * | ||
FROM city | ||
WHERE id = 1661; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SELECT * | ||
FROM city | ||
WHERE countrycode = 'JPN'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
name | ||
FROM | ||
city | ||
WHERE | ||
countrycode = 'JPN'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT | ||
city, | ||
state | ||
FROM | ||
station; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT | ||
DISTINCT city | ||
FROM | ||
station | ||
WHERE | ||
id % 2 = 0; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT | ||
( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
station | ||
) - ( | ||
SELECT | ||
COUNT(DISTINCT city) | ||
FROM | ||
station | ||
); |
This file contains 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