Dbms Ope Friday-2
Dbms Ope Friday-2
1. Write a SQL query to find the host team id and the guest team id of the
matches played before MAY 15, 2020, in which the host team scored
more than 2 goals. [FLIS]
2. Write a SQL query to find the name of the managers whose names
contain at least six characters. [FLIS]
select name
from managers
where name like ‘______%’
Or,
select name
from managers
where length(name) >= 6
3. Write a SQL query to find the member type and member number of the
female students who are from the department code ‘EE’. [LIS]
5. Write a SQL query to find the name of the product ordered by user
‘EVIE’ on ‘2023-11-05’. [Eshop]
select product_name
from product p
join orders o on p.product_id = o.product_id
join users u on o.user_id = u.user_id
where user_name = ‘EVIE’ and date_ordered = ‘2023-11-05’
Or,
select product_name
from product
where product_id = (
select product_id
from orders
where date_ordered = ‘2023-11-05’ and user_id = (
select user_id
from users
where user_name = ‘EVIE’
)
)
6. Write a SQL query to find the name of referees who were the fourth
referee for match numbers ‘M0001’, ‘M0003’, ‘M0005’. [FLIS]
select name
from referees r
inner join match_referees mr on r.referee_id = mr.fourth_referee
where match_num in(‘M0001’, ‘M0003’, ‘M0005’)
7. Write a SQL query to find the title, date of issue (doi) of the books issued
by the students whose first name starts with ‘S’ and from departments
‘Mechanical Engineering’ or ‘Computer Science’. [LIS]
Or,
8. For the database connection, use the following connection string
variables:
Problem Statement:
Users
user_id varchar(20)
name varchar(30)
dob date
email varchar(50)
phone_num int
# This except block will catch both the general Python exception and
PostgreSQL(Database) related errors and print them to the console
except(Exception, psycopg2.DatabaseError) as error:
print(error)
referee_id → name