Single Row Subquery Returns more than one row

Hi

I have an error in the code.

Please advise.


Leon
SELECT 		account_reference, ice_customer_id, key_type, parent_account_reference, parent_key_type, product_code, business_flag, start_date, end_date, account_type, account_name, domain
    FROM	   (SELECT 	    ice1.*, 
                            1 AS domain
                FROM        ice1.account ice1
                UNION ALL 
                SELECT 		ice2.*, 
                            2 AS domain
                FROM        ice2.account ice2)
    WHERE account_reference = (SELECT account_reference
                               FROM          (SELECT 	    ice1.*, 
                                                            1 AS domain
                                              FROM          ice1.base ice1
                                              UNION ALL 
                                              SELECT 		ice2.*, 
                                                            2 AS domain
                                              FROM          ice2.base ice2)
                               WHERE key_type IN (1,2,14,15)
                               AND (product_status = 'LI' 
                               OR (product_status = 'RC' AND start_date<SYSDATE)
                               OR (product_status IN('PL','PG') AND start_date>SYSDATE)))

Open in new window

SimpleIntelligenceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RiteshShahCommented:
try now

SELECT          account_reference, ice_customer_id, key_type, parent_account_reference, parent_key_type, product_code, business_flag, start_date, end_date, account_type, account_name, domain
    FROM           (SELECT          ice1.*, 
                            1 AS domain
                FROM        ice1.account ice1
                UNION ALL 
                SELECT          ice2.*, 
                            2 AS domain
                FROM        ice2.account ice2) as t
    WHERE account_reference = (SELECT account_reference
                              FROM          (SELECT         ice1.*, 
                                                        1 AS domain
                                            FROM        ice1.base ice1
                
                                            UNION ALL 
                                            SELECT              ice2.*, 
                                                2 AS domain
                                            FROM        ice2.base ice2)  as t1
                                WHERE           key_type IN (1,2,14,15)
                                AND 
                                   (product_status = 'LI' 
                                OR (product_status = 'RC' AND start_date<SYSDATE)
                                OR (product_status IN('PL','PG') AND start_date>SYSDATE)))

Open in new window

0
RiteshShahCommented:
one more this, you may have to use

 WHERE account_reference IN

rather than.

 WHERE account_reference =
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SimpleIntelligenceAuthor Commented:
Thanks Ritesh. Job done.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.