[Programmers / MySQL] Level 1 Animal IDs and Names (59403)
[Programmers / MySQL] Level 1 Animal IDs and Names (59403)
The ANIMAL_INS table is a table containing information about animals that have entered an animal shelter. The ANIMAL_INS table structure is as follows, where ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, and SEX_UPON_INTAKE represent the animal's ID, species, intake date, condition at intake, name, and sex/neuter status, respectively.
@RWBwritten at 2021-12-15 14:58:28
| Rank | Language Used |
|---|---|
| Level 1 | 🖼️ MySQL |
The ANIMAL_INS table is a table containing information about animals that have entered an animal shelter. The ANIMAL_INS table structure is as follows, where ANIMAL_ID, ANIMAL_TYPE, DATETIME, INTAKE_CONDITION, NAME, and SEX_UPON_INTAKE represent the animal's ID, species, intake date, condition at intake, name, and sex/neuter status, respectively.
| NAME | TYPE | NULLABLE |
|---|---|---|
| ANIMAL_ID | VARCHAR(N) | FALSE |
| ANIMAL_TYPE | VARCHAR(N) | FALSE |
| DATETIME | DATETIME | FALSE |
| INTAKE_CONDITION | VARCHAR(N) | FALSE |
| NAME | VARCHAR(N) | TRUE |
| SEX_UPON_INTAKE | VARCHAR(N) | FALSE |
Write a SQL statement to retrieve the ID and name of every animal that entered the shelter, sorted by ANIMAL_ID. Running the SQL should produce the following output:
| ANIMAL_ID | NAME |
|---|---|
| A349996 | Sugar |
| A350276 | Jewel |
| A350375 | Meo |
| A352555 | Harley |
| A352713 | Gia |
| A352872 | Peanutbutter |
| A353259 | Bj |
((the rest is omitted))
Retrieve the ANIMAL_ID and NAME of every animal. Sort the results in ascending order by ANIMAL_ID.
SQL
SELECT ANIMAL_ID, NAME FROM ANIMAL_INS ORDER BY ANIMAL_ID;
# Programmers# Algorithm# SQL# Level 1
