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

  • SEARCH
  • Home
  • 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 8568725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:10:28+00:00 2026-06-11T18:10:28+00:00

I want to do a minus operation on two tables in an Oracle DB.

  • 0

I want to do a minus operation on two tables in an Oracle DB. The first table is Chart_Year that has trackPosition, trackArtist, trackName, previewLink in it. The other table is Recommendation that has just trackArtist, trackName, previewLink in it. I want the final table to be ordered by trackPosition. The way I do it is order by trackArtist:

SELECT trackartist, trackname, previewlink 
FROM 
    (
        SELECT 
            trackposition, trackartist, trackname, previewlink 
        FROM 
            chart_year 
        WHERE 
            chartsYear between 2004 and 2008 
        ORDER BY trackposition ASC
    )

MINUS 

SELECT 
    trackartist, trackname, previewlink 
FROM 
    recommendation 
WHERE 
    user = 'bla'

Maybe I can do something like

SELECT 
    1 as trackPosition, trackartist, trackname, previewlink 
FROM 
    recommendation...

?

  • 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-11T18:10:30+00:00Added an answer on June 11, 2026 at 6:10 pm

    Instead of MINUS, you can use EXISTS:

    SELECT trackartist, trackname, previewlink
      FROM chart_year cy
     WHERE chartsYear BETWEEN 2004 AND 2008
       AND NOT EXISTS
            ( SELECT 1
                FROM recommendation r
               WHERE r.user = 'bla'
                 AND r.trackartist = cy.trackartist
                 AND r.trackname = cy.trackname
                 AND r.previewlink = cy.previewlink
            )
     ORDER
        BY trackposition ASC
    ;
    

    Or a LEFT OUTER JOIN:

    SELECT cy.trackartist, cy.trackname, cy.previewlink
      FROM chart_year cy
      LEFT
     OUTER
      JOIN recommendation r
        ON r.user = 'bla'
       AND r.trackartist = cy.trackartist
       AND r.trackname = cy.trackname
       AND r.previewlink = cy.previewlink
     WHERE cy.chartsYear BETWEEN 2004 AND 2008
       AND r.user IS NULL -- i.e., where the join failed
     ORDER
        BY cy.trackposition ASC
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let us say I have two table types (tables of object types) that I
I want to recreate the rotating minus button that Apple uses in it's UITableViews
I have two tables, posts and sections. I want to get the last 10
Basically I want to have that middle blue body part scroll minus the scrollbar
I want to ORDER BY the result of a MINUS query. My first attempt
I am creating one query. In that query i want minus date from system
What is the correct syntax for Minus Query in MS ACCESS I want to
Hi I have two dropdown menus: priceMaximum and mortgageMaximum I want it so if
I know that with a large site you would want to separate footers, menus,
I want to substract two numbers, one is the contents of a field, the

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.