Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:46:56+00:00 2026-06-04T23:46:56+00:00

Using the BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using an OUTER JOIN

  • 0

Using the BOOK_ORDER, ORDER_ITEMS, and BOOKS tables, create a query using an OUTER JOIN operation that will list the book title, order date, and order number for all books in the BOOKS table. Order your output in descending order by ORDER_ITEMS.BOOKID. There are three books that have never been ordered which should show up at the top of your listing.

I wrote this query:-

SELECT B.TITLE, BO.ORDERDATE, ORD.ORDERID FROM BOOKS B, BOOK_ORDER BO, ORDERITEMS ORD
WHERE B.BOOKID = ORD.BOOKID
AND BO.ORDERID = ORD.ORDERID(+)
ORDER BY ORD.ORDERID DESC

I am getting the results but confused about this following part of the question:-

“There are three books that have never been ordered which should show up at the top of your listing.”

I am guessing this mean I need to display those Books that have Orderdate and OrderId as NULL or blank. But how do I get those rows on top of the result set? What should I change in the query that I have written?

This is the BOOKS table:-

Name                                      Null?    Type
----------------------------------------- -------- ---------------
BOOKID                                    NOT NULL NUMBER(15)
ISBN                                               VARCHAR2(10)
TITLE                                              VARCHAR2(30)
PUBDATE                                            DATE
PUBID                                              NUMBER(2)
COST                                               NUMBER(5,2)
RETAIL                                             NUMBER(5,2)
CATEGORY                                           VARCHAR2(12)

This is ORDER_ITEMS table:-

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------
 ORDERID                                   NOT NULL NUMBER(4)
 ITEMNUM                                   NOT NULL NUMBER(2)
 BOOKID                                    NOT NULL NUMBER(15)
 QUANTITY                                           NUMBER(3)

and here is BOOK_ORDER table structure:-

 Name                                      Null?    Type
 ----------------------------------------- -------- --------------
 ORDERID                                   NOT NULL NUMBER(4)
 CUSTOMERID                                         NUMBER(4)
 ORDERDATE                                          DATE
 SHIPDATE                                           DATE
 SHIPSTREET                                         VARCHAR2(20)
 SHIPCITY                                           VARCHAR2(20)
 SHIPSTATE                                          VARCHAR2(2)
 SHIPZIP                                            VARCHAR2(5)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:46:57+00:00Added an answer on June 4, 2026 at 11:46 pm

    try this:

    SELECT B.TITLE,
           BO.ORDERDATE,
           ORD.ORDERID
    FROM BOOKS B,
         BOOK_ORDER BO,
         ORDER_ITEMS ORD
    WHERE B.BOOKID = ORD.BOOKID(+)
      AND BO.ORDERID(+) = ORD.ORDERID
    ORDER BY ORD.ORDERID DESC
    

    By the way, IMHO, it’s better not to use the (+) operator but the ANSI JOIN keywords:

    SELECT B.TITLE,
           BO.ORDERDATE,
           ORD.ORDERID
    FROM BOOKS B
    LEFT OUTER JOIN ORDER_ITEMS ORD ON B.BOOKID = ORD.BOOKID
    FULL OUTER JOIN  BOOK_ORDER BO ON BO.ORDERID = ORD.ORDERID
    ORDER BY ORD.ORDERID DESC
    

    here is a fiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 db tables: books(id, title, author,...) and orders(id, book_id, user_id,...) and users(id,
An Android book I have states that using TextToSpeech.playEarcon() is preferable to playing audio
I'm using a book called Android Wireless Application Development 2nd edition 2009 (L.Darcey &
I'm using Google Book Search API to add missings bits and pieces to my
So I have started learning directx11 using a book by Frank D.Luna. His examples
I am trying to learn some PHP using the book titled PHP for Absolute
This is an example out of a book using northwind database. What is the
I was trying to use the function glMultiDrawElements while studying OpenGL (using red book)
I'm starting learning Ocaml, using hickey book , and I'm stuck on Exercise 3.4,
I'm a newb to RoR. I'm using the book Agile Web Development with Rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.