Skip to content

Commit 0761449

Browse files
committed
Add basic select sql problems
1 parent 797e2fd commit 0761449

File tree

15 files changed

+43
-1
lines changed

15 files changed

+43
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div align="center">
22
<img src="https://github.com/alexprut/HackerRank/raw/master/hackerrank-logo.png" width="450" height="auto"/>
33

4-
[![Solutions](https://img.shields.io/badge/solutions-409-green.svg?style=flat-square)](https://github.com/alexprut/HackerRank#table-of-contents)
4+
[![Solutions](https://img.shields.io/badge/solutions-423-green.svg?style=flat-square)](https://github.com/alexprut/HackerRank#table-of-contents)
55
[![Languages](https://img.shields.io/badge/languages-c%2B%2B%2Cjava%2Chaskell-yellow.svg)](https://github.com/alexprut/HackerRank#table-of-contents)
66
[![Author](https://img.shields.io/badge/author-alexprut-brightgreen.svg?style=flat-square)](https://www.hackerrank.com/alexprut)
77
[![MIT](https://img.shields.io/dub/l/vibe-d.svg?style=flat-square)](https://github.com/alexprut/HackerRank/blob/master/LICENSE)
@@ -59,6 +59,7 @@ platform tests of a given problem.
5959
1. [Mathematics](#mathematics)
6060
1. [Artificial Intelligence](#artificial-intelligence)
6161
1. [Linux Shell](#linux-shell)
62+
1. [Sql](#sql)
6263

6364
## Algorithms
6465
|Subdomain|Challenge|Difficulty|Score|Solution|
@@ -514,6 +515,24 @@ platform tests of a given problem.
514515
|Grep Sed Awk|['Sed' command #2](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-2)|Medium|2|[Solution.txt](Linux%20Shell/Grep%20Sed%20Awk/'Sed'%20command%20#2/Solution.txt)|
515516
|Grep Sed Awk|['Sed' command #3](https://www.hackerrank.com/challenges/text-processing-in-linux-the-sed-command-3)|Easy|2|[Solution.txt](Linux%20Shell/Grep%20Sed%20Awk/'Sed'%20command%20#3/Solution.txt)|
516517

518+
## Sql
519+
|Subdomain|Challenge|Difficulty|Score|Solution|
520+
|-|-|-|-|-|
521+
|Basic Select|[Revising the Select Query I](https://www.hackerrank.com/challenges/revising-the-select-query)|Easy|10|[Solution.txt](Sql/Basic%20Select/Revising%20the%20Select%20Query%20I/Solution.txt)|
522+
|Basic Select|[Revising the Select Query II](https://www.hackerrank.com/challenges/revising-the-select-query-2)|Easy|10|[Solution.txt](Sql/Basic%20Select/Revising%20the%20Select%20Query%20II/Solution.txt)|
523+
|Basic Select|[Select All](https://www.hackerrank.com/challenges/select-all-sql)|Easy|10|[Solution.txt](Sql/Basic%20Select/Select%20All/Solution.txt)|
524+
|Basic Select|[Select By ID](https://www.hackerrank.com/challenges/select-by-id)|Easy|10|[Solution.txt](Sql/Basic%20Select/Select%20By%20ID/Solution.txt)|
525+
|Basic Select|[Japanese Cities' Attributes](https://www.hackerrank.com/challenges/japanese-cities-attributes)|Easy|10|[Solution.txt](Sql/Basic%20Select/Japanese%20Cities'%20Attributes/Solution.txt)|
526+
|Basic Select|[Japanese Cities' Names](https://www.hackerrank.com/challenges/japanese-cities-name)|Easy|10|[Solution.txt](Sql/Basic%20Select/Japanese%20Cities'%20Names/Solution.txt)|
527+
|Basic Select|[Weather Observation Station 1](https://www.hackerrank.com/challenges/weather-observation-station-1)|Easy|15|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%201/Solution.txt)|
528+
|Basic Select|[Weather Observation Station 3](https://www.hackerrank.com/challenges/weather-observation-station-3)|Easy|10|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%203/Solution.txt)|
529+
|Basic Select|[Weather Observation Station 4](https://www.hackerrank.com/challenges/weather-observation-station-4)|Easy|10|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%204/Solution.txt)|
530+
|Basic Select|[Weather Observation Station 5](https://www.hackerrank.com/challenges/weather-observation-station-5)|Easy|30|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%205/Solution.txt)|
531+
|Basic Select|[Weather Observation Station 6](https://www.hackerrank.com/challenges/weather-observation-station-6)|Easy|10|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%206/Solution.txt)|
532+
|Basic Select|[Weather Observation Station 7](https://www.hackerrank.com/challenges/weather-observation-station-7)|Easy|10|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%207/Solution.txt)|
533+
|Basic Select|[Weather Observation Station 8](https://www.hackerrank.com/challenges/weather-observation-station-8)|Easy|15|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%208/Solution.txt)|
534+
|Basic Select|[Weather Observation Station 9](https://www.hackerrank.com/challenges/weather-observation-station-9)|Easy|10|[Solution.txt](Sql/Basic%20Select/Weather%20Observation%20Station%209/Solution.txt)|
535+
517536
License
518537
=======
519538
Licensed under [MIT](LICENSE).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT * FROM CITY WHERE COUNTRYCODE = "JPN"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT DISTINCT NAME FROM CITY WHERE COUNTRYCODE = "JPN"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT * FROM CITY WHERE POPULATION > 100000 AND COUNTRYCODE = "USA"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT NAME FROM CITY WHERE POPULATION > 120000 and COUNTRYCODE = "USA" GROUP BY(NAME)

Sql/Select All/Solution.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT * FROM CITY

Sql/Select By ID/Solution.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT * FROM CITY WHERE ID = 1661
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT CITY, STATE FROM STATION
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT DISTINCT CITY FROM STATION WHERE ID % 2 = 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT (COUNT(CITY) - COUNT(DISTINCT CITY)) FROM STATION
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY), CITY LIMIT 1;
2+
SELECT CITY, LENGTH(CITY) FROM STATION ORDER BY LENGTH(CITY) DESC, CITY LIMIT 1;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT CITY FROM STATION
2+
WHERE CITY LIKE 'a%'
3+
OR CITY LIKE 'e%'
4+
OR CITY LIKE 'i%'
5+
OR CITY LIKE 'o%'
6+
OR CITY LIKE 'u%'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SELECT DISTINCT CITY FROM STATION WHERE LOWER(SUBSTR(CITY,LENGTH(CITY),1)) IN ('a','e','i','o','u');
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select distinct city from station
2+
where left(city,1) in ('a','e','i','o','u')
3+
and right(city, 1) in ('a','e','i','o','u')
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
select distinct city from station
2+
where left(city,1) not in ('a','e','i','o','u')

0 commit comments

Comments
 (0)