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 7916403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:47:39+00:00 2026-06-03T14:47:39+00:00

Hey i’m using oracle sql to create a database. I im now working on

  • 0

Hey i’m using oracle sql to create a database.

I im now working on queries and i have come up with two seperate quires which i would like to merge in order to get a result.

The first query i have created is to find out the total money made by a performance:

    SELECT SUM(bookings * CategoryPrice )AS Total_Money_Made
    FROM ( SELECT CategoryPrice , count(*) AS bookings
       FROM Booking b
       JOIN performance per
         ON b.performanceid =  per.performanceid
       JOIN Production p
         ON per.productionid = p.productionid          
      WHERE per.performanceid IN (1, 2, 3, 4)
      GROUP BY CategoryPrice)

This gives me a result of:

TOTAL_MONEY_MADE

       337.5 

Then i have another query which works out the total concession money:

              SELECT SUM(ConsessionAmount * 2) AS Total_Consession_Money
      FROM( SELECT COUNT (*) AS ConsessionAmount
FROM Booking 
WHERE 
Consession = 'Yes' AND PerformanceID = '1' OR 
Consession = 'Yes' AND PerformanceID = '2' OR 
Consession = 'Yes' AND PerformanceID = '3' OR 
Consession = 'Yes' AND PerformanceID = '4' )

This gives me result of:

TOTAL_CONSESSION_MONEY

                18 

Now i want a way that i can subtract the result from the second query from the first query. is it possible? and how can i do it? i think it has something to do with sub-queries but im not too sure.

Any help?
Thanks.

  • 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-03T14:47:40+00:00Added an answer on June 3, 2026 at 2:47 pm

    You could do it like this:

    WITH TOTAL_MADE
    AS
    (   
        SELECT SUM(bookings * CategoryPrice )AS Total_Money_Made
        FROM ( SELECT CategoryPrice , count(*) AS bookings
           FROM Booking b
           JOIN performance per
             ON b.performanceid =  per.performanceid
           JOIN Production p
             ON per.productionid = p.productionid          
          WHERE per.performanceid IN (1, 2, 3, 4)
          GROUP BY CategoryPrice)
    ), TOTAL_CONSESSION
    AS
    (
        SELECT SUM(ConsessionAmount * 2) AS Total_Consession_Money
          FROM( SELECT COUNT (*) AS ConsessionAmount
        FROM Booking 
        WHERE 
        Consession = 'Yes' AND PerformanceID = '1' OR 
        Consession = 'Yes' AND PerformanceID = '2' OR 
        Consession = 'Yes' AND PerformanceID = '3' OR 
        Consession = 'Yes' AND PerformanceID = '4' )
    )
    SELECT
        TOTAL_CONSESSION.Total_Consession_Money-
        TOTAL_MADE.Total_Money_Made AS Something
    FROM
        TOTAL_MADE,
        TOTAL_CONSESSION;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey right now I'm using jQuery and I have some global variables to hold
Hey I have an array with numbers in it. Now I want to divide
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey all i have two JFrames one is my main login frame, user enters
Hey guys here is my question. im using JCombobox. if a student have CB
hey guys I have two divs- with id=form1 which is inline and the other
Hey I'm working on a startup and I've got to build a simple database
Hey friends i have use 2 text view now when i fetch data from
Hey guys, I'm working on a project. I need to use the function cvFindHomography
Hey, I'm trying to create Like Buttons for Facebook Photos, but can't figure out

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.