[SQL]HZ_PARTIES HZ_CUST_ACCOUNTS

Oracle sql hz_parties hz_cust_accounts

SELECT cust.cust_account_id customer_id,
       SUBSTRB(party.party_name, 1, 50) customer_name,
       cust.account_number customer_number,
       party.customer_key customer_key,
       cust.status status,
       cust.orig_system_reference orig_system_reference,
       'CUSTOMER' customer_prospect_code,
       party.category_code customer_category_code,
       cust.customer_class_code customer_class_code,
       cust.customer_type customer_type,
       cust.primary_salesrep_id primary_salesrep_id,
       DECODE(party.party_type, 'ORGANIZATION', party.sic_code, NULL) sic_code,
       party.tax_reference tax_reference,
       cust.tax_code tax_code,
       cust.fob_point fob_point,
       cust.ship_via ship_via,
       DECODE(party.party_type, 'ORGANIZATION', party.gsa_indicator_flag, 'N') gsa_indicator,
       cust.ship_partial ship_partial,
       party.jgzz_fiscal_code taxpayer_id,
       cust.price_list_id price_list_id,
       cust.freight_term freight_term,
       cust.order_type_id order_type_id,
       cust.sales_channel_code sales_channel_code,
       cust.warehouse_id warehouse_id,
       DECODE(party.party_type, 'ORGANIZATION', party.mission_statement, NULL) mission_statement,
       DECODE(party.party_type, 'ORGANIZATION', party.employees_total, TO_NUMBER(NULL)) num_of_employees,
       DECODE(party.party_type, 'ORGANIZATION', party.curr_fy_potential_revenue, TO_NUMBER(NULL)) potential_revenue_curr_fy,
       DECODE(party.party_type, 'ORGANIZATION', party.next_fy_potential_revenue, TO_NUMBER(NULL)) potential_revenue_next_fy,
       DECODE(party.party_type, 'ORGANIZATION', party.fiscal_yearend_month, NULL) fiscal_yearend_month,
       DECODE(party.party_type, 'ORGANIZATION', party.year_established, TO_NUMBER(NULL)) year_established,
       DECODE(party.party_type, 'ORGANIZATION', party.analysis_fy, NULL) analysis_fy,
       party.competitor_flag competitor_flag,
       party.reference_use_flag reference_use_flag,
       party.third_party_flag third_party_flag,
       cust.attribute_category attribute_category,
       cust.attribute1 attribute1,
       cust.attribute2 attribute2,
       cust.attribute3 attribute3,
       cust.attribute4 attribute4,
       cust.attribute5 attribute5,
       cust.attribute6 attribute6,
       cust.attribute7 attribute7,
       cust.attribute8 attribute8,
       cust.attribute9 attribute9,
       cust.attribute10 attribute10,
       cust.attribute11 attribute11,
       cust.attribute12 attribute12,
       cust.attribute13 attribute13,
       cust.attribute14 attribute14,
       cust.attribute15 attribute15,
       cust.last_updated_by last_updated_by,
       cust.last_update_date last_update_date,
       cust.last_update_login last_update_login,
       cust.created_by created_by,
       cust.creation_date creation_date,
       DECODE(party.party_type, 'ORGANIZATION', party.organization_name_phonetic, NULL) customer_name_phonetic,
       cust.tax_header_level_flag tax_header_level_flag,
       cust.tax_rounding_rule tax_rounding_rule,
       cust.global_attribute_category global_attribute_category,
       cust.global_attribute1 global_attribute1,
       cust.global_attribute2 global_attribute2,
       cust.global_attribute3 global_attribute3,
       cust.global_attribute4 global_attribute4,
       cust.global_attribute5 global_attribute5,
       cust.global_attribute6 global_attribute6,
       cust.global_attribute7 global_attribute7,
       cust.global_attribute8 global_attribute8,
       cust.global_attribute9 global_attribute9,
       cust.global_attribute10 global_attribute10,
       cust.global_attribute11 global_attribute11,
       cust.global_attribute12 global_attribute12,
       cust.global_attribute13 global_attribute13,
       cust.global_attribute14 global_attribute14,
       cust.global_attribute15 global_attribute15,
       cust.global_attribute16 global_attribute16,
       cust.global_attribute17 global_attribute17,
       cust.global_attribute18 global_attribute18,
       cust.global_attribute19 global_attribute19,
       cust.global_attribute20 global_attribute20
FROM   hz_cust_accounts cust,
       hz_parties party
WHERE  cust.party_id = party.party_id;