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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:22:52+00:00 2026-06-04T18:22:52+00:00

I work with an Oracle database that has tables for customers, chains and campaigns.

  • 0

I work with an Oracle database that has tables for customers, chains and campaigns. Like so (stripped down):

TABLE CUSTOMER 
  ACCOUNTNUMBER   VARCHAR2
  CHAIN           VARCHAR2
  CATEGORY        VARCHAR2

TABLE CHAIN
  CODE            VARCHAR2
  PARENTCHAIN     VARCHAR2

TABLE CAMPAIGN
  ID              NUMBER
  DISCOUNT        NUMBER

TABLE CAMPAIGN_ELIGIBILITY
  CAMPAIGNID      NUMBER   --ID of the campaign
  ACCOUNTNUMBER   VARCHAR2 --Customer included in the campaign
  CHAINCODE       VARCHAR2 --Chain included in the campaign
  CUSTCATCODE     VARCHAR2 --Customercategory included in the campaign

A customer can be eligible for a campaign specifically (based on accountnumber), through his defined customergroup or as a member of a chain.

I use this query to find all campaigns that are valid for a given customer:

select * from campaign where id in
(
  select unique campaignid from campaign_eligibility where 
    accountnumber=:accountnumber
  union
  select unique campaignid from campaign_eligibility where 
    chaincode = 
      (select chain from debtable where accountnumber=:accountnumber)
  union
  select unique campaignid from campaign_eligibility where 
    custcatcode =
      (select category from customer where accountnumber=:accountnumber)
) 

Now, let’s say that the customer “Popeye Spinach Empire” is a member of the chain “Spinach Dealers Inc.”, which in turn is part of the larger chain “GreenFud R US”, which in turn is part of the chain “FoAC”. When there’s a campaign that targets “GreenFud R US”, Popeye is eligible for that campaign. My query will only return campaigns where Popeye has been specifically added, or that targets “Spinach Dealers Inc.”

How can I modify my query to include campaigns that a customer is indirectly part of?

  • 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-04T18:22:53+00:00Added an answer on June 4, 2026 at 6:22 pm
    WITH    chains AS
            (
            SELECT  code
            FROM    chain c
            START WITH
                    c.code IN
                    (
                    SELECT  chain
                    FROM    campaign_eligibility
                    WHERE   accountnumber = :acc
                    UNION ALL
                    SELECT  chain
                    FROM    customer c
                    JOIN    campaign_eligibility ce
                    ON      ce.custcatcode = c.category
                    WHERE   accountnumber = :acc
                    UNION ALL
                    SELECT  chain
                    FROM    customer
                    WHERE   accountnumber = :acc
                    )
            CONNECT BY
                    c.code = PRIOR c.parentchain
            ) ch
    SELECT  *
    FROM    campaign
    WHERE   c.id IN
            (
            SELECT  campaignid
            FROM    chains 
            JOIN    campaign_eligibility ce
            ON      ce.chaincode = c.code
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Fluent NHibernate on a project that has an Oracle 10g database.
I have a query that joins two tables. One table has a column that
I have two tables (A and G) in an Oracle database that can be
Does LINQPad work with Oracle? Has anyone tried? What do you suggest?
Im working on a legacy oracle database with a slightly odd table naming convention
I have setup a simple Oracle external table test that I (alongside a DBA
Today's problem is as follows: we have a table in an Oracle database. The
I have a large Oracle database ( 720,000 records aprox) where each record has
Now that Oracle supports EF officially (at least in Beta), EF looks like a
I have a table that has a one to many relationship with itself. Each

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.