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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:46:03+00:00 2026-05-25T12:46:03+00:00

I’m trying to check whether certain features in Product A are all also featured

  • 0

I’m trying to check whether certain features in Product A are all also featured in Product B. We count the amount of how many such Product B’s there are that fully fulfill all of the features of Product A.

My query returns the correct value for the Count, however, I want it to display 0 where there are no such Product B’s that have the features of Product A. At the moment, it is only returning the values where the count is greater than 1.

For a further explanation please refer to the following code:

SELECT P1.Product_ID, COUNT(P2.Product_ID) AS NUMBER
FROM Products P1, PRODUCTS P2
WHERE P1.Product_ID != P2.Product_ID 
      AND
NOT EXISTS (
            ( SELECT FEATURELIST.feature_id
              FROM FEATURELIST
              WHERE FEATURELIST.Product_ID = P1.Product_ID)
              MINUS
            ( SELECT FEATURELIST.feature_id
              FROM FEATURELIST
              WHERE FEATURELIST.Product_ID = P2.Product_ID )
            )
GROUP BY P1.PNO;

This returns something that looks like:

Product_ID    |    NUMBER
1                    2
5                    7
13                   2
17                   4

I want it to return the full Product_ID list.. so something like this:

    Product_ID    |    NUMBER
     1                    2
     2                    0
     3                    0
     4                    0
     5                    7
     6                    0
     7                    0
     ..                   ..
     17                   4

Using oracle sql.

  • 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-05-25T12:46:03+00:00Added an answer on May 25, 2026 at 12:46 pm

    A simple solution might be to UNION all products with a default COUNT of 0 and perform an additional GROUP BY on the results.

    SELECT  P1.Product_ID, SUM(NUMBER) AS NUMBER
    FROM    (
              SELECT  P1.Product_ID, 0 AS NUMBER
              FROM    Products P1
              UNION ALL
              SELECT  P1.Product_ID, COUNT(P2.Product_ID) AS NUMBER
              FROM    Products P1, PRODUCTS P2
              WHERE   P1.Product_ID != P2.Product_ID 
                      AND NOT EXISTS (
                          ( SELECT FEATURELIST.feature_id
                            FROM FEATURELIST
                            WHERE FEATURELIST.Product_ID = P1.Product_ID)
                            MINUS
                          ( SELECT FEATURELIST.feature_id
                            FROM FEATURELIST
                            WHERE FEATURELIST.Product_ID = P2.Product_ID )
                          )
              GROUP BY P1.PNO
            ) P1
    GROUP BY
            P1.Product_ID        
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

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.