# 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;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dailyjournal.gitbook.io/solutions/hackerrank-solutions/prepare/sql/basic-select.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
