# Basic Select

## Revising the Select Query I

{% embed url="<https://www.hackerrank.com/challenges/revising-the-select-query/problem?isFullScreen=true>" %}

```sql
select * from CITY
where POPULATION > 100000
and COUNTRYCODE = 'USA';
```

## Revising the Select Query II

{% embed url="<https://www.hackerrank.com/challenges/revising-the-select-query-2/problem?isFullScreen=true>" %}

```sql
select NAME from CITY
where POPULATION > 120000
and COUNTRYCODE = 'USA';
```

## Select All

{% embed url="<https://www.hackerrank.com/challenges/select-all-sql/problem?isFullScreen=true>" %}

```sql
select * from CITY;
```

## Select By ID

{% embed url="<https://www.hackerrank.com/challenges/select-by-id/problem?isFullScreen=true>" %}

```sql
select * from CITY
where ID = 1661;
```

## Japanese Cities' Attributes

{% embed url="<https://www.hackerrank.com/challenges/japanese-cities-attributes/problem?isFullScreen=true>" %}

```sql
select * from CITY 
where COUNTRYCODE = 'JPN';
```

## Japanese Cities' Names

{% embed url="<https://www.hackerrank.com/challenges/japanese-cities-name/problem?isFullScreen=true>" %}

```sql
select NAME from CITY
where COUNTRYCODE = 'JPN';
```

## Weather Observation Station 1

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-1/problem?isFullScreen=true>" %}

```sql
select CITY, STATE from STATION;
```

## Weather Observation Station 3

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-3/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION
where mod(ID, 2) = 0;
```

## Weather Observation Station 4

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-4/problem?isFullScreen=true>" %}

```sql
select count(CITY) - count(distinct CITY) from STATION;
```

## Weather Observation Station 5

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-5/problem?isFullScreen=true>" %}

```sql
select CITY, length(CITY) from(
    select CITY from STATION 
    order by length(CITY), CITY asc) 
where rownum = 1; 

select CITY, length(CITY) from(
    select CITY from STATION 
    order by length(CITY) desc) 
where rownum = 1;
```

## Weather Observation Station 6

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-6/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION
where lower(substr(CITY,1,1)) in ('a','e','i','o','u');
```

## Weather Observation Station 7

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-7/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION
where lower(substr(CITY,-1,1)) in ('a','e','i','o','u');
```

## Weather Observation Station 8

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-8/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION 
where lower(substr(CITY,1,1)) in ('a','e','i','o','u')
and lower(substr(CITY,-1,1)) in ('a','e','i','o','u');
```

## Weather Observation Station 9

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-9/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION 
where lower(substr(CITY,1,1)) not in ('a','e','i','o','u');
```

## Weather Observation Station 10

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-10/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION
where lower(substr(CITY,-1,1)) not in ('a','e','i','o','u');
```

## Weather Observation Station 11

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-11/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION
where lower(substr(CITY,1,1)) not in ('a','e','i','o','u')
or lower(substr(CITY,-1,1)) not in ('a','e','i','o','u');
```

## Weather Observation Station 12

{% embed url="<https://www.hackerrank.com/challenges/weather-observation-station-12/problem?isFullScreen=true>" %}

```sql
select distinct CITY from STATION
where lower(substr(CITY,1,1)) not in ('a','e','i','o','u')
and lower(substr(CITY,-1,1)) not in ('a','e','i','o','u');
```

## Higher Than 75 Marks

{% embed url="<https://www.hackerrank.com/challenges/more-than-75-marks/problem?isFullScreen=true>" %}

```sql
select Name from STUDENTS
where Marks > 75
order by substr(Name,-3,3), ID asc;
```

## Employee Names

{% embed url="<https://www.hackerrank.com/challenges/name-of-employees/problem?isFullScreen=true>" %}

```sql
select name from Employee
order by name asc;
```

## Employee Salaries

{% embed url="<https://www.hackerrank.com/challenges/salary-of-employees/problem?isFullScreen=true>" %}

```sql
select name from Employee
where salary > 2000
and months < 10
order by employee_id asc;
```
