Question 1: Find all instructors that belong to the “Physics” Department: (just the name) sql answer



Download 28,27 Kb.
Sana04.06.2022
Hajmi28,27 Kb.
#635884
Bog'liq
Saydirasulov Jamoliddin Exercise 1


Question 1:
Find all instructors that belong to the “Physics” Department: (just the name)


SQL answer:
select name
from instructor where dept_name=”Physics”


Rational algebra answer:
σ dept_name=”Physics” (instructors)


Question 2:
Find the instructor with the highest salary: (name and id)


SQL answer:
select name, ID, Max(Salary)
from instructor


Rational algebra answer:
instructor.salaryinstructor.salary < d,salary (instructor x ρd (instructor)))
Question 3:
Find the average salary in every department:


SQL answer:
SELECT avg(salary)
from instructor


Rational algebra answer:
G avg(salary) (instructor)
Question 4:
Show which department has the highest as average salary:


SQL answer:
SELECT max(SALARY) as avgSalary
FROM instructor


Rational algebra answer:
G max(salary) avgSalary(instructor)
Question 5:
Show all courses that were NOT taught in the year 2017


SQL answer:
select *
from course
where year=2017 and course = null


Rational algebra answer:
∏course_id (σ semester=null Λ year=2017 (section))
Question 6:
Please provide an alternative to the following SQL statements without using “INTERSECT”
(select course_id from section where sem = 'Fall' and year = 2017)
intersect
(select course_id from section where sem = 'Spring' and year = 2018)


SQL answer:
select course_id from section where semester = 'Fall' and year = 2017
EXCEPT
select course_id from section where semester = 'Spring' and year = 2018


Rational algebra answer:
course_idsemester=“Fall” Λ year=2009 (section)) U ∏course_id semester=“Spring” Λ year=2010 (section))


Bonus question:
Yossi has decided to rewrite the following SQL statement without using the word “between”

select name


from instructor
where salary between 90000 and 100000
He wrote:
select name
from instructor
where salary > 90000 and salary < 100000
Was he correct? Can you fix his query?


SQL answer :
SELECT name
FROM instructor
WHERE salary > 90000 AND salary<100000;


Rational algebra answer:
name(instructor)
salary >= 90000 salary<=100000
Download 28,27 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish