0% found this document useful (0 votes)
30 views

SQL Billing Error List - SQL

This document contains a SQL query that selects various data fields from multiple database tables related to billing segments, meter readings, service accounts, and more. It joins these tables together on primary and foreign keys to retrieve associated data for billing segments that are active after July 1, 2023 and have meter reads, account characteristics, and other relevant information. The query filters for power service accounts and includes meter configuration details to populate the selected fields.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

SQL Billing Error List - SQL

This document contains a SQL query that selects various data fields from multiple database tables related to billing segments, meter readings, service accounts, and more. It joins these tables together on primary and foreign keys to retrieve associated data for billing segments that are active after July 1, 2023 and have meter reads, account characteristics, and other relevant information. The query filters for power service accounts and includes meter configuration details to populate the selected fields.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

SELECT

sa.acct_id,
sa.sa_type_cd,
sac.adhoc_char_val,
bs.bseg_id,
bs.start_dt,
bs.end_dt,
bs.bseg_stat_flg,
-- bse.exp_msg,
bsr.start_reg_reading,
bsr.end_reg_reading,
rr2.read_type_flg,
mr.read_dttm,
rr.read_type_flg,
rr.reg_reading,
mrc.char_val,
acc.srch_char_val est_excp,
acc2.srch_char_val topc,
acc3.srch_char_val minb
FROM
ci_bseg bs,
ci_bseg_excp bse,
ci_bseg_read bsr,
ci_reg_read rr2,
ci_sa sa,
ci_sa_sp sasp,
ci_sp_mtr_hist sph,
ci_sa_char sac,
ci_acct_char acc,
ci_acct_char acc2,
ci_acct_char acc3,
ci_bseg bs2,
ci_mr mr,
ci_mr_char mrc,
ci_reg_read rr
WHERE
bs.bseg_id = bse.bseg_id (+)
-- and bs.bseg_id='012937356469'
AND bs.bseg_stat_flg < '50'
AND bs.sa_id = sa.sa_id
AND sa.sa_type_cd LIKE 'P-W-%'
AND sa.sa_id = sasp.sa_id
AND sasp.sp_id = sph.sp_id
AND sph.removal_dttm IS NULL
AND sa.sa_id = sac.sa_id (+)
AND sac.char_type_cd (+) = 'DLY_AVG'
AND sa.acct_id = acc.acct_id (+)
AND acc.char_type_cd (+) = 'CMESTEXC'
AND sa.acct_id = acc2.acct_id (+)
AND acc2.char_type_cd (+) = 'CMTOPCON'
AND sa.acct_id = acc3.acct_id (+)
AND acc3.char_type_cd (+) = 'CM-MINB'
AND bs.sa_id = bs2.sa_id
AND bs2.bseg_stat_flg = '50'
AND bs2.end_dt = (
SELECT
MAX(bs3.end_dt)
FROM
ci_bseg bs3
WHERE
bs3.bseg_stat_flg = '50'
AND bs3.sa_id = sa.sa_id
)
AND mr.mtr_config_id = sph.mtr_config_id
AND mr.use_on_bill_sw = 'Y'
AND mr.read_dttm = (
SELECT
MAX(mr2.read_dttm)
FROM
ci_mr mr2
WHERE
mr2.mtr_config_id = mr.mtr_config_id
AND mr2.use_on_bill_sw = 'Y'
)
AND mr.mr_id = mrc.mr_id (+)
AND mrc.char_type_cd (+) = 'ESTRULE'
AND mr.mr_id = rr.mr_id
AND mr.use_on_bill_sw = 'Y'
AND bs.ilm_dt > '24-SEP-2023'
and bs.end_dt>'01-JUL-2023'
and bs.bseg_id=bsr.bseg_id(+)
and rr2.read_type_flg(+)='30'
and bsr.seqno(+)='1'
and bsr.end_reg_read_id=rr2.reg_read_id(+)
and rr2.read_seq(+)='1'
and bs.bseg_stat_flg='30'
-- and trim(bsr.start_reg_reading)<>trim(bsr.end_reg_Reading)

--AND bse.exp_msg(+) = 'System Error. Please see logs for more details.'

You might also like