-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path040.sql
More file actions
36 lines (30 loc) · 961 Bytes
/
040.sql
File metadata and controls
36 lines (30 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Q: Display patient's full name, height in the units feet rounded to 1 decimal, weight in the unit pounds rounded to 0 decimals, birth_date, gender non abbreviated.
Convert CM to feet by dividing by 30.48.
Convert KG to pounds by multiplying by 2.205.
Table Info: patients
+--------------+----------+
| Column Name | Type |
+--------------+----------+
| patient_id | INT |
| first_name | TEXT |
| last_name | TEXT |
| gender | CHAR(1) |
| birth_date | DATE |
| city | TEXT |
| province_id | CHAR(2) |
| allergies | TEXT |
| height | INT |
| weight | INT |
+--------------+----------+
*/
-- SOLUTION:
select
concat(first_name, ' ', last_name) as patient_name,
round(height/30.48,1) as 'height "Feet"',
round(weight*2.205,0) as 'weight "Pounds"',
birth_date,
case
when gender = 'M' then 'MALE'
else 'FEMALE'
end as gender_type
from patients;