Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Customer BILL_TO and SHIP_TO in the same row

User_B9XGOSep 29 2016 — edited Sep 29 2016

Hi All,

I am using Oracle Applications R12 Standard tables for the below query:

SELECT  DISTINCT hca.account_number,

(SELECT cust_acct_site_id  FROM hz_cust_site_uses_all hc WHERE hcas.cust_acct_site_id =hc.cust_acct_site_id AND  site_use_code = 'BILL_TO' AND hc.primary_flag = 'Y') Bill_to_Loc_Id,

(SELECT cust_acct_site_id  FROM hz_cust_site_uses_all hc WHERE hcas.cust_acct_site_id =hc.cust_acct_site_id AND  site_use_code = 'SHIP_TO' AND hc.primary_flag = 'Y') Ship_to_Loc_Id   

           FROM hz_cust_accounts hca,

                hz_cust_acct_sites_all hcas,              

                hz_parties hp

          WHERE     hca.cust_account_id = hcas.cust_account_id                                                                                    

                AND hca.party_id = hp.party_id

                AND hca.account_number=100;

I want to get the Bill to site id and Ship to site id in one row as below:

Required O/P:

Account_number    Bill_to_Loc_Id      Ship_to_Loc_Id   

100                                       211                  311

But I am getting the o/p as 2 records as below:      

O/P:

Account_number    Bill_to_Loc_Id      Ship_to_Loc_Id   

100                                  211                 

100                                                                 311

Could anyone please help me on this.

Thanks,

KVR

This post has been answered by Frank Kulash on Sep 29 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2016
Added on Sep 29 2016
10 comments
7,511 views