0% found this document useful (0 votes)
22 views4 pages

Houssein Alaeddine DataBase Lecture 3

test

Uploaded by

Ice Tech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Houssein Alaeddine DataBase Lecture 3

test

Uploaded by

Ice Tech
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Client

ALL ID
1
Name
Alaeddine
Salary
1500
2 Darwich 2000
Query: Find the client having
3 Beydoun 1800
the maximum salary?
10 Fares 1200

SELECT * FROM client


WHERE salary >All
( Salary
SELECT salary FROM client 1500
WHERE salary < ANY 1800
1
(SELECT salary FROM client) 1200

)
What about the minimum
ID Name Salary salary ?
2 Darwich 2000 Dr. Houssein Alaeddine
Join 3 tables
Client City Country
ID Name CityId ID Name CountryId ID Name
1 Alaeddine 3 1 Baalbeck 1 1 Lebanon
2 Darwich 1 2 Tripoli 1 2 Libya
3 Beydoun 2 3 Beirut 1
10 Fares 4 4 Tripoli 2

Query: Show the names of clients and their cities and countries?
2
SELECT cl.name Client_Name,ci.name City_Name,co.name Country_Name
FROM Client as cl INNER JOIN City as ci
ON cl.CityId=ci.ID
INNER JOIN Country co
on ci.CountryId=co.ID
Dr. Houssein Alaeddine
Exercise
Agency (NumAgency, Name, City, Asset)
Client (NumClient, Name, City)
Account(NumAccount, NumAgency, NumClient, Balance)
Loan (NumLoan, NumAgency, NumClient, Amount)

List

1. Agencies having client accounts.


3
2. Clients having account in ‘Baalbeck’ agencies.
3. Clients having account but not loan in ‘Beyrouth’agencies.
4. Clients having account in the same agency as ‘Darwich’.
5. Agencies having higher asset than all agencies of ‘Baalbeck’.

Dr. Houssein Alaeddine


Data NumAgency Name
Agency
City Asset
Client 100 Hello Baalbeck 12000
NumClient Name City 101 Again Beirut 15000
1 Alaeddine Beirut
102 Bye Baalbeck 25000
2 Darwich Baalbeck
103 Good Nabatieh 20000
3 Fares Nabatieh
104 Very Beirut 18000

Loan
Account NumLoan NumAgency NumClient Amount
NumAccount NumAgency NumClient Balance 100 101 2 1000
1 4 102 2 5000 101 102 1 500
2 101 3 2000 ID Name
102 102 3 200
3 103 1 1500 1 Lebanon
103 101 2 500
4 104 2 2000 2 Libya
104 103 1 600
105 104 3 1000
Dr. Houssein Alaeddine

You might also like