SQL query client fetch that has all the products

Hi all

I need a SQL query to retrieve the output as shown

Table: ACCOUNT_SUMMARY

prod_id Cust_id

101 AAA

BBB 101

101. THE CCC

102 AAA

103 AAA

102. THE CCC

: Table

Prod_id Prod_desc

101 Home_loan

Vehicle loan 102

Loan education 103

Expected results:

Cust_id Prod_desc

AAA Home_loan

AAA auto loan

Educational ready AAA

Sorry, could not understand your question clearly.

Do you want this:

WITH account_summary
                  AS (SELECT 101 prod_id,'AAA' cust_id FROM dual UNION ALL
                      SELECT 101,'BBB' FROM dual UNION ALL
                      SELECT 101,'CCC' FROM dual UNION ALL
                      SELECT 102,'AAA' FROM dual UNION ALL
                      SELECT 103,'AAA' FROM dual UNION ALL
                      SELECT 102,'CCC' FROM dual)
    ,Product
          AS (SELECT 101 prod_id,'Home_loan' prod_desc FROM dual UNION ALL
              SELECT 102,'Vehicle loan' FROM dual UNION ALL
              SELECT 103,'Educational Loan' FROM dual
              )
  , acc_count
      AS  (SELECT prod_id, cust_id ,count(*) OVER (PARTITION BY cust_id) cnt
            FROM account_summary
            )
SELECT A.prod_id,P.prod_desc
FROM acc_count A, product P
WHERE A.prod_id = P.prod_id
AND  cnt = (SELECT count(*) FROM product)
ORDER BY A.prod_id

Tags: Database

Similar Questions

Maybe you are looking for

  • Hola App does not work on Ipad 2 Air any work arounds?

    I contacted Hola VPN and followed their advice (re-installed and changed the application settings). I can't access on my Ipad 2 Air Hola. Can someone advise me on this? The application allows you to view TV in other countries... I pay for the app htt

  • Will Firefox be configured to update for non-admins on windows 7/8

    We are considering allowing Firefox in our hospital of 5000 users and are currently all Internet Exploder. None of our users are so admins on hospital systems, is it possible to push updates for windows systems 7/8? I'm help doing the doorbell, just

  • RN4220 and the FOURTH all losses of data for TWO years

    Hello team NTGR and customers. I want to tell you a failstory. Two years ago, I was looking for a BIG SIN store backups of my data from the company. I have already had several old Pro RND 6 boxes and selected 4220 x 12 4 hard drives of WD RE CT. pric

  • "cooling fan does not work correctly.

    Product name: HP Pavilion dv6 Notebook PC Product number: LZ801PA #ACJ Operating system: Windows 7 64-bit Erroe message: "The system has detected a cooling fan does not work correctly. . Continued operation is not recommended and can result in unpred

  • I forgot my Windows password, how do I connect to my computer.

    original title: password I forgot my password to connect to my computer and I am the adminastrator.  How do I ge on the computer without it?  I also have some files on there that I don't want to lose.