100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Databases - Basic SQL iSubmit Exam with Answers

Rating
-
Sold
-
Pages
15
Grade
9-10
Uploaded on
01-01-2025
Written in
2020/2021

Basic SQL syntax questions with answers for the course Databases, BSc AI.

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Study
Course

Document information

Uploaded on
January 1, 2025
Number of pages
15
Written in
2020/2021
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Basic SQL syntax
The first names of all students
select first
from Students

The first names of all students living in Springfield
select first
from Students
where address = 'Springfield'

Last names of all students with first name George
select last
from Students
where first = 'George'

select first
from Students S
where S.last = 'Orwell'

Combining Students and Results
select *
from Students as S, Results as R
where S.sid = R.sid -- join condition

Joins of multiple tables
The results of George Orwell
select first, last, category, number, points
from Students as S, Results as R
where S.sid = R.sid -- join condition
and first = 'George' and last = 'Orwell'

Joining three tables: all results of George Orwell
select S.first, S.last, E.category, E.number, R.points, E.maxPoints
from Students S, Results R, Exercises E
where S.sid = R.sid -- join condition for S-R
and R.category = E.category and R.number = E.number -- join condition for R-E
and S.first = 'George' and S.last = 'Orwell'

Persons who take classes
select P.name, C.kind
from Persons P, Classes C, TakesClasses T
where P.id = T.person_id
and C.id = T.class_id




1

, All students that have 9 points in homework 1 and 2
select S.first, S.last
from Students S, Results R1, Results R2
where S.sid = R1.sid
and S.sid = R2.sid
and R1.category = 'homework' AND R1.number = 1
and R2.category = 'homework' AND R2.number = 2
and R1.points >= 9 AND R2.points >= 9

Persons who like someone with blue eyes
select distinct PA.name
from Persons PA, Persons PB, Likes L
where PA.id = L.personA_id and PB.id = L.personB_id
and PB.eyeColor = "blue"

Persons who like at least two people with green eyes
select distinct PA.name
from Persons PA, Persons PB, Likes L
where PA.id = L.personA_id and PB.id = L.personB_id
and PB.eyeColor = "green"
group by PA.name
having count(*) >= 2

Men that play soccer with a female player
select distinct P.name
from Persons P, Persons PA, Persons PB, SportTogether S
where PA.id = S.personA_id and PB.id = S.personB_id
and (PA.name = P.name or PB.name = P.name)
and (P.gender = 'male' and PA.gender <> PB.gender)
and S.sport = 'soccer'

Last names without duplicates
select distinct last
from Students

(Inner) join
SELECT A.name, B.name
FROM TableA A JOIN TableB B
ON A.id = B.id

Left (outer) join
SELECT A.name, B.name
FROM TableA A LEFT JOIN TableB B
ON A.id = B.id


2
$9.57
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Document also available in package deal

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
tararoopram Vrije Universiteit Amsterdam
Follow You need to be logged in order to follow users or courses
Sold
26
Member since
3 year
Number of followers
2
Documents
38
Last sold
1 month ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can immediately select a different document that better matches what you need.

Pay how you prefer, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card or EFT and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions