Exercise DT
Exercise DT
: Date :
1. Using the Global Fast Foods database, retrieve the customer’s first name, last name, and
address for the customer who uses ID 456.
Solution:
2. Show the name, start date, and end date for Global Fast Foods' promotional item “ballpen and
highlighter” giveaway.
Solution:
4. The following query was supposed to return the CD title "Carpe Diem" but no rows were
returned. Correct the mistake in the statement and show the output.
SELECT produce, title
FROM d_cds
WHERE title = 'carpe diem' ;
Solution:
5. The manager of DJs on Demand would like a report of all the CD titles and years of CDs that
were produced before 2000.
Solution:
7. Write a SQL statement that will display the student number (studentno), first name (fname),
and last name (lname) for all students who are female (F) in the table named students.
Solution:
8. Write a SQL statement that will display the student number (studentno) of any student who
has a PE major in the table named students. Title the studentno column Student Number.
Solution:
9. Write a SQL statement that lists all information about all male students in the table named
students.
Solution:
10. Write a SQL statement that will list the titles and years of all the DJs on Demand's CDs that
were not produced in 2000.
Solution:
11. Write a SQL statement that lists the Global Fast Foods employees who were born before
1980.
Solution:
Ex. No. : Date :
Comparison Operators
1. Display the first name, last name, and salary of all Global Fast Foods staff whose salary is
between $5.00 and $10.00 per hour.
Solution:
2. Display the location type and comments for all DJs on Demand venues that are Private Home.
Solution:
3. Using only the less than, equal, or greater than operators, rewrite the following query:
4. Create a list of all the DJs on Demand CD titles that have “a” as the second letter in the title.
Solution:
5. Who are the partners of DJs on Demand who do not get an authorized expense amount?
Solution:
6. Select all the Oracle database employees whose last names end with “s”. Change the heading
of the column to read Possible Candidates.
Solution:
8. Write a SQL statement that lists the songs in the DJs on Demand inventory that are type code
77, 12, or 1.
Solution:
Ex. No. : Date :
1. Execute the two queries below. Why do these nearly identical statements produce two
different results? Name the difference and explain why.
SELECT code, description
FROM d_themes
WHERE code >200 AND description IN('Tropical', 'Football', 'Carnival');
SELECT code, description
FROM d_themes
WHERE code >200 OR description IN('Tropical', 'Football', 'Carnival');
Solution:
2. Display the last names of all Global Fast Foods employees who have “e” and “i” in their last
names.
Solution:
3. “I need to know who the Global Fast Foods employees are that make more than $6.50/hour
and their position is not order taker.”
Solution:
4. Using the employees table, write a query to display all employees whose last names start with
“D” and have “a” and “e” anywhere in their last name.
Solution:
5. In which venues did DJs on Demand have events that were not in private homes?
Solution:
6. Which list of operators is in the correct order from highest precedence to lowest precedence?
a. AND, NOT, OR
b. NOT, OR, AND
c. NOT, AND, OR
Solution:
7. Who am I?
I was hired by Oracle after May 1998 but before June of 1999. My salary is less than $8000 per
month, and I have an “en” in my last name.
Solution:
Sorting Rows
1. In the example below, assign the employee_id column the alias of “Number.” Complete the
SQL statement to order the result set by the column alias.
SELECT employee_id, first_name, last_name
FROM employees;
Solution:
2. Create a query that will return all the DJs on Demand CD titles ordered by year with titles in
alphabetical order by year.
Solution:
3. Order the DJs on Demand songs by descending title. Use the alias "Our Collection" for the
song title.
Solution:
4. Write a SQL statement using the ORDER BY clause that could retrieve the information needed.
Solution:
5. Write a SQL statement using the employees table and the ORDER BY clause that could
retrieve the information in the following table. Return only those employees with
employee_id<125.
Solution: