0% found this document useful (0 votes)
9 views2 pages

Tutorial 5 - SQL - Sol

The document provides solutions for a database tutorial focusing on SQL queries. It includes various SELECT statements to retrieve data from different tables such as publisher, orders, customers, and books, with specific conditions and formatting. The solutions emphasize the differences between Access SQL and Oracle SQL syntax.

Uploaded by

choyforgift
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)
9 views2 pages

Tutorial 5 - SQL - Sol

The document provides solutions for a database tutorial focusing on SQL queries. It includes various SELECT statements to retrieve data from different tables such as publisher, orders, customers, and books, with specific conditions and formatting. The solutions emphasize the differences between Access SQL and Oracle SQL syntax.

Uploaded by

choyforgift
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

SEHH2240 database Systems

Tutorial 5 Solution

(Note: Please try to Do It Yourself FIRST before reading the solutions.


And note that slight differences do exist between Access SQL and Oracle SQL)

1. SELECT name, contact AS [Contact Person], phone


FROM publisher;

2. SELECT DISTINCT customerId


FROM orders;

3) SELECT title, (retail-cost)/cost*100 AS [Profit %]


FROM books;

If round the result to 2 decimal place

SELECT title, round((retail-cost)/cost*100, 2) AS [Profit %]


FROM books;

4) SELECT *
FROM customers
WHERE city = 'AUSTIN' or city = 'SEATTLE'
ORDER BY lastname;

5) SELECT *
FROM orders
WHERE orderdate < #02-APR-2020#;

6) SELECT *
FROM Author
WHERE Lname LIKE ‘*IN*’
ORDER BY Lname, Fname;

7) SELECT *
FROM customers
WHERE referred IS NOT NULL;

8) SELECT *
FROM books
WHERE category LIKE 'C*N*';

9) SELECT *
FROM books
WHERE title LIKE '?A?N*';
10) SELECT title, cost, retail, retail-cost AS Profit
FROM books
WHERE retail-cost >= 10
ORDER BY retail-cost desc;

11) SELECT *
FROM books
WHERE category IN ('COMPUTER', 'FAMILY LIFE')
AND pubid IN (1,3)
AND retail >= 45;

You might also like