我创建了一个查询来返回每天的银行对账单行数。
出于某种原因,当有一个对账单传入时,会有两行相同的银行帐户名。一行返回0表示语句行总数,另一行返回正确的语句行数。
如果当天没有输入语句行,则查询只返回一行0作为总语句行,这是正确的。
请帮忙。
select distinct cb.bank_name,
cba.bank_account_name Bank_Account_Name,
cba.bank_account_num Bank_Account_Number,
le.name Legal_entity_Name,
(select count(csl1.STATEMENT_LINE_ID)
from ce_statement_lines csl1
where to_char(csl1.booking_date,'yyyy/MM/dd') = to_char(:P_Date,'yyyy/MM/dd')
and csl1.STATEMENT_HEADER_ID = CESL.STATEMENT_HEADER_ID
--GROUP BY cba.bank_account_id, csl1.STATEMENT_LINE_ID
) total_statement_line_for_date
from
ce_bank_accounts cba,
xle_entity_profiles le,
CE_STATEMENT_HEADERS CESH,
ce_banks_v cb,
ce_statement_lines CESL
WHERE cba.account_owner_org_id = le.legal_entity_id
and cb.bank_party_id = cba.bank_id
and cba.bank_account_id = CESH.BANK_ACCOUNT_ID
and CESL.STATEMENT_HEADER_ID = CESH.STATEMENT_HEADER_ID
-- GROUP BY cb.bank_name, cba.bank_account_name, cba.bank_account_num, le.name, cba.bank_account_id
order by cba.bank_account_name
|----------------|------------------|------------------ |-------|------|
| Bank Name |Bank Account Name |Bank Account Number|LE Name| Count|
|----------------|------------------|-------------------|-------|------|
| A Name | A Account Name | A Account Number | A LE | 0 |
|----------------|------------------|-------------------|-------|------|
| B Name | B Account Name | B Account Number | B LE | 0 |
|----------------|------------------|-------------------|-------|------|
| B Name | B Account Name | B Account Number | B LE | 17 |
|----------------|------------------|-------------------|-------|------|
| C Name | C Account Name | C Account Number | C LE | 0 |
|----------------|------------------|-------------------|-------|------|
| C Name | C Account Name | C Account Number | C LE | 1 |
|----------------|------------------|-------------------|-------|------|
1条答案
按热度按时间o4tp2gmn1#
我更喜欢示例数据,但是-如果您对当前查询感到满意,并且它做了您希望它做的事情,但也希望摆脱
count = 0
如果有行count
价值观不是0
,那么一个简单的选项是