【发布时间】:2019-01-02 00:52:03
【问题描述】:
我遇到了一个问题,我想获得字段的最大长度,因为我想知道是否存在超过为该字段建立的大小的字段,例如:varchar2(20)
我用的是oracle 11g,看看这个:
https://i.stack.imgur.com/4DdWM.jpg
所以,我做了这个查询:
SELECT
hp.party_name
, hca.account_number
, hca.cust_account_id
-- , hcsu.LOCATION customer_site_name
, hcas.cust_acct_site_id
, hcp.phone_number
, hcp.email_address
, hl.address1
, hl.address2
, hl.address3
, hl.address4
, hl.city
, hl.province
, hl.postal_code
, hcas.status
, DECODE( hcas.attribute5, 'PUP', 'Y', 'N' )
, hca.status
FROM apps.hz_cust_accounts hca
INNER JOIN apps.hz_cust_acct_sites_all hcas ON hca.cust_account_id = hcas.cust_account_id
INNER JOIN apps.hz_party_sites hps ON hcas.party_site_id = hps.party_site_id
INNER JOIN apps.hz_locations hl ON hps.location_id = hl.location_id
INNER JOIN apps.hz_parties hp ON hps.party_id = hp.party_id
LEFT JOIN (
SELECT
owner_table_id
, max(case when contact_point_type = 'PHONE' then phone_number end) phone_number
, max(case when contact_point_type = 'EMAIL' then email_address end) email_address
FROM hz_contact_points
WHERE status = 'A'
AND primary_flag = 'Y'
AND owner_table_name = 'HZ_PARTY_SITES'
AND contact_point_type IN ('EMAIL','PHONE')
AND length (phone_number) > 40
GROUP BY
owner_table_id
) hcp ON hcas.party_site_id = hcp.owner_table_id
WHERE hcas.status = 'A'
AND hps.status = 'A'
AND hca.status = 'A'
AND hca.account_number = ''
;
我设置了这个条件 "AND length (phone_number) > 40" 但它不起作用,因为它显示空字段,为什么?
看看这个: IMAGE
还有,这种情况可以吗?
hcp ON hcas.party_site_id = hcp.owner_table_id
你能帮我解决这个问题吗?
PS:我正在使用 SQL DEVELOPER 和 oracle 数据库 11g
【问题讨论】:
-
请不要张贴(链接到)表格结构、代码或查询结果的图片,使用文字。