SQL1 in Class Exercise

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

SQL 1

Question 1

1. Write down the result of the following SQL query.


SELECT customer-id, customer-city
FROM CUST
2
Question 2, Question 3, and Question 4
2. Consider the table in Question 1. Suppose that we want to
“find the tuples for customers living in Pittsfield”, what
should be the SQL query?

3. Consider the table in Question 1. Write the SQL query to only


display the names of the customers living in ‘Pittsfield’.

4. Consider the table in Question 1. Write the SQL query to find


the names of the customers who are living in the ‘Park’ street
in city ‘Pittsfield’.

3
Question 5 and Question 6
5) Consider the table in Question 1. What is the result for the following
SQL query?
SELECT customer-id
FROM CUST
WHERE customer-street LIKE ‘N%’ OR customer-city LIKE ‘H_%’

6) Consider the following tables.

Write the SQL query to find the names of owners of accounts with
balances at least 30k.
4
Question 7 and Question 8
7. Consider the tables in Question 6. Find the acc-ids of all
accounts except the one with the largest balance.
HINT: You can rename the table with the name NAME to N in
the FROM clause by using the following SQL query.
SELECT *
FROM NAME N

8. Consider the tables in Question 6. Find the acc-id of the account


with the largest balance.

You might also like