取客户信息SQL

本文提供了一个详细的SQL查询示例,用于从多个业务表中联接并检索客户信息,包括客户名称、地址、应收账户等详细数据。该查询还考虑了各种过滤条件,如客户状态、组织ID等。
--客户信息  
SELECT hou.name 业务实体
      ,hca.account_number 客户编号
      ,hca.cust_account_id
      ,hp.party_name 客户名称
      ,arp_addr_pkg.format_address(hl.address_style
                                  ,hl.address1
                                  ,hl.address2
                                  ,hl.address3
                                  ,hl.address4
                                  ,hl.city
                                  ,hl.county
                                  ,hl.state
                                  ,hl.province
                                  ,hl.postal_code
                                  ,ftv.territory_short_name) 地址
      ,flv.meaning 用途
      ,gcc_rec.concatenated_segments 应收帐户
      ,gcc_rev.concatenated_segments 收入帐户
FROM   hz_parties               hp
      ,hz_party_sites           hps
      ,hz_locations             hl
      ,hz_cust_accounts         hca
      ,hz_cust_acct_sites_all   hcas
      ,hz_cust_site_uses_all    hcs
      ,fnd_lookup_values        flv
      ,fnd_territories_vl       ftv
      ,gl_code_combinations_kfv gcc_rev
      ,gl_code_combinations_kfv gcc_rec
      ,hr_operating_units       hou
WHERE  hp.party_id = hca.party_id
AND    hp.party_id = hps.party_id
AND    hps.location_id = hl.location_id
AND    hca.cust_account_id = hcas.cust_account_id
AND    hps.party_site_id = hcas.party_site_id
AND    hl.country = ftv.territory_code(+)
AND    hcas.cust_acct_site_id = hcs.cust_acct_site_id
AND    flv.lookup_code = hcs.site_use_code
AND    hcs.gl_id_rec = gcc_rec.code_combination_id(+)
AND    hcs.gl_id_rev = gcc_rev.code_combination_id(+)
AND    hou.organization_id = hcas.org_id
AND    hca.status = 'A'
AND    hps.status = 'A'
AND    hcs.status = 'A'
AND    flv.lookup_type = 'SITE_USE_CODE'
AND    flv.lookup_code = 'BILL_TO'
AND    flv.language = 'ZHS'
AND    hou.organization_id = 81 --p_org_id  
AND    hca.cust_account_id = 21046 --p_customer_id  
ORDER  BY hou.name
         ,hca.account_number;
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

鱼鱼章

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值