butterflyTee 0 Light Poster

USING:ORACLE 9i

For each of the following tasks, determine (a) the SQL statement needed to perform the stated task using the traditional approach and (b) the SQL statement needed to perform the stated task the JOIN keyword.

A list that displays the title of each book & the name and phone number of the person at the publisher's office whom you would need to contact to record each book.

SELECT title, name, customer
FROM books JOIN publisher
WHERE books.pubid = publisher.pubid
AND
c.books = record

Determine which orders have not yet shipped & the name of the customer that placed each order. Sort results by dates on the orders was placed.

SELECT lastname, firstname, order#
FROM customers c, orders, o
WHERE c.customer# = o.customer#(+)
ORDER BY c.customer#;

List the customer number & names of all individuals have purchased books in the Fitness Category.

SELECT title, firstname, lastname
FROM customers, orders, orderitems, books
WHERE customers.customer#=orders.customer#
AND orders.order#=orderitems.order#
AND orderitems.isbn=books.isbn
ORDER BY title = (‘Fitness’)

Determine book Jake Lucas has purchased.

SELECT lastname, firstname, order#
FROM customers c OUTER JOIN orders o
ON c.customer# = o.customers#
ORDER BY c.customers# = (‘Jake Lucas’)

Determine profit of each book sold to Jake Lucas. Sort results by date of order. If more than 1 book was ordered, have results sorted by profit amount in descending order.
SELECT lastname, firstname, order#
FROM customers, orders, orderitems, books
WHERE "Profit"
ORDER BY "Profit" desc;


Which book was written by an author with the last name Adams?

SELECT title, authorid
FROM books, bookauthor
WHERE author ('ADAMS')


What gift will a customer who orders the book Shortest Poems receive?

SELECT title, customer, gift
FROM books, promotion ('Shortest Poem')
ON retail BETWEEN minretail AND maxretail


Identify the author(s) of books ordered by Becca Nelson

SELECT lastname, firstname, title, authorid
FROM books, bookauthor
WHERE authors
ORDER BY ('Becca Nelson')


Display list of all books in BOOKS table. If a book has been ordered by a customer, also list the corresponding order number(s) & state which the customer resides.

SELECT lastname, firstname, state, books, order#
FROM state s, customers c, orders o
WHERE c. customer# AND s. customer# = o. customer#

Produce a list of all customers live in the state of Florida & ordered books about computers.

SELECT lastname, firstname, state, books, order#
FROM state s, customers c, orders o ('Florida')
WHERE c. customer# AND s. customer# = o. customer#
ORDER BY ('Computers')


:mad: :twisted: :sad:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.