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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:14:01+00:00 2026-06-05T21:14:01+00:00

I have an oracle 10g database that has 2 tables: a REBATES table, and

  • 0

I have an oracle 10g database that has 2 tables: a REBATES table, and an ORDERS table.

The REBATES table looks sort of like this:

| rebate_percentage | min_purchase |
------------------------------------
| 1.0               | 5000         |
| 1.5               | 7000         |
| 2.0               | 11000        |
| 5.0               | 20000        |

I’m trying to determine the rebate percentage to apply, based on total orders. I know how to find the sum of all orders for a particular customer, for a particular time range, but how do I also grab the rebate percentage, all in one query?

For example, if the order total is 16,000 then how can I construct a query that takes this value, compares it against the REBATES table, and returns 2.0?

  • 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-05T21:14:02+00:00Added an answer on June 5, 2026 at 9:14 pm

    In my opinion, the easiest way is if you have a min and max purchase amounts:

    select rebate_percentage, min_purchase,
           (lead(min_purchase, 1) over (order by min_purchase) - 1) as max_purchase
    from rebates
    

    Then you can do a simple between join, where the join condition looks like:

    on totalorders between rebates.min_purchase and rebates.max_purchase
    

    You can handle the final case (with NULLs) with a modified join condition:

    on totalorders >= rebates.min_purchase and
        (totalorders <= rebates.max_purchase or rebates.max_purchase is null)
    

    Or, alternatively, by changing the original logic to have a coalesce() on the lead function with some very large value.

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

Sidebar

Related Questions

I have created a table on an Oracle 10g database with this structure :
I am working with an Oracle 10g Database. I have the following two tables:
I have an Excel file (which has data imported from Oracle 10G Database) one
Imagine I have a database with one table, this table has only one field
I have written a C# application that connects to an Oracle 10g database. Using
I have an oracle graphics application that works with a 10G database, however with
I have an Oracle 10g database of genomic data with several >100 million row
I have installed Oracle 10g Express Edition database on a server and install the
I have a PL/SQL package in an Oracle 10g database and I want to
I have an INSERT query in Oracle 10g that is getting stuck on a

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.