KnowledgeBoat Logo

Informatics Practices

Dr. Kavita has created a database for a hospital's pharmacy. The database includes a table named MEDICINE whose column (attribute) names are mentioned below:

MID: Shows the unique code for each medicine.

MED_NAME: Specifies the medicine name.

SUPP_CITY: Specifies the city where the supplier is located.

STOCK: Indicates the quantity of medicine available.

DEL_DATE: Specifies the date when the medicine was delivered.

Table: MEDICINE

MIDMED_NAMESUPP_CITYSTOCKDEL_DATE
M01PARACETAMOLMUMBAI2002023-06-15
M02AMOXICILLINKOLKATA502023-03-21
M03COUGH SYRUPBENGALURU1202023-02-10
M04INSULINCHENNAI1352023-01-25
M05IBUPROFENAHMEDABAD302023-04-05

Write the output of the following SQL Queries.

I. Select LENGTH(MED_NAME) from MEDICINE where STOCK > 100;

II. Select MED_NAME from MEDICINE where month(DEL_DATE) = 4;

III. Select MED_NAME from MEDICINE where STOCK between 120 and 200;

IV. Select max(DEL_DATE) from MEDICINE;

SQL Queries

1 Like

Answer

I.

Output
+------------------+
| LENGTH(MED_NAME) |
+------------------+
|               11 |
|               11 |
|                7 |
+------------------+

II.

Output
+-----------+
| MED_NAME  |
+-----------+
| IBUPROFEN |
+-----------+

III.

Output
+-------------+
| MED_NAME    |
+-------------+
| PARACETAMOL |
| COUGH SYRUP |
| INSULIN     |
+-------------+

IV.

Output
+---------------+
| max(DEL_DATE) |
+---------------+
| 2023-06-15    |
+---------------+

Answered By

2 Likes


Related Questions