我使用以下查询来检索数据。它在大多数情况下工作正常,但是对于特定情况,我收到错误" ORA-24347聚合函数中的空列警告"我试图使用NVL,但仍然无法工作。请指教。感谢。
SELECT RT.RATE_AGREEMENT_NBR,
RT.AMENDMENT_NBR,
DECODE ( TO_CHAR ( RT.rate_effective_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.amendment_effective_dt, RT.rate_effective_dt ) RATE_EFFECTIVE_DT,
DECODE ( TO_CHAR ( RT.rate_expiration_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.CURR_AGREEMENT_EXPIRATION_DT, RT.rate_expiration_dt ) RATE_EXPIRATION_DT,
RT.ORIGINAL_EXPIRATION_DT,
RT.RATE_DELETE_FLG,
RT.RATE_COMPONENT_CD,
RT.VALIDATION_FLG,
RT.RATE_PCT,
RT.RATE_QTY,
RT.RECEIVE_MODE_CD,
RT.DELIVERY_MODE_CD,
RT.INCLUDE_FLG,
RT.DNH_FLG,
RT.SERVICE_MODE_CD,
RT.ORIGIN_GOVERNING_BODY_CD,
RT.ORIGIN_PRICING_LOC_GROUP_CD,
RT.DEST_GOVERNING_BODY_CD,
RT.DEST_PRICING_LOCATION_GROUP_CD,
RT.ORIGIN_LOCATION_CD,
RT.DESTINATION_LOCATION_CD,
RT.ORIGIN_DESCRIPTION_TXT,
RT.DESTINATION_DESCRIPTION_TXT,
RT.APL_PRIMARY_CURRENCY_CD,
RT.DATATIZED_RATE_FLG,
RT.SYSTEM_GENERATED_FLG,
RT.LAST_UPDATE_USER_ID_CD,
RT.ORIGIN_VIA_GOVERNING_BODY_CD,
RT.ORIGIN_VIA_PRICING_LOC_GRP_CD,
RT.ORIGIN_VIA_LOCATION_CD,
RT.DEST_VIA_GOVERNING_BODY_CD,
RT.DEST_VIA_PRICING_LOC_GROUP_CD,
RT.DEST_VIA_LOCATION_CD,
RT.PREPAID_COLLECT_FLG,
CR.COMMODITY_BLIND_KEY_NBR,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.RATE_COMPONENT_AMT, NULL )) XR,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_R,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.RATE_BASIS_CD )) RATE_BASIS_CD_R,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_R,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.UOM_CD, '' )) UOM_CD_R,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.UOM_TYPE_CD )) UOM_TYPE_CD_R,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_R,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.RATE_COMPONENT_AMT, NULL )) XD,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.RATE_BASIS_CD )) RATE_BASIS_CD_D,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.UOM_CD, '' )) UOM_CD_D,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.UOM_TYPE_CD )) UOM_TYPE_CD_D,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_D,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.RATE_COMPONENT_AMT, NULL )) X20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.RATE_BASIS_CD )) RATE_BASIS_CD_20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.UOM_CD, '' )) UOM_CD_20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.UOM_TYPE_CD )) UOM_TYPE_CD_20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '20', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.RATE_COMPONENT_AMT, NULL )) X40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.UOM_CD, '' )) UOM_CD_40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.RATE_COMPONENT_AMT, NULL )) X45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.RATE_BASIS_CD )) RATE_BASIS_CD_45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.UOM_CD, '' )) UOM_CD_45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.UOM_TYPE_CD )) UOM_TYPE_CD_45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '45', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.RATE_COMPONENT_AMT, NULL )) X48,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.RATE_BASIS_CD )) RATE_BASIS_CD_48,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.UOM_CD, '' )) UOM_CD_48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.UOM_TYPE_CD )) UOM_TYPE_CD_48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '48', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_48,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.RATE_COMPONENT_AMT, NULL )) XD20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.RATE_BASIS_CD )) RATE_BASIS_CD_D20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.UOM_CD, '' )) UOM_CD_D20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.UOM_TYPE_CD )) UOM_TYPE_CD_D20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D20', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_D20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.RATE_COMPONENT_AMT, NULL )) XD40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_D40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.UOM_CD, '' )) UOM_CD_D40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_D40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_D40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.RATE_COMPONENT_AMT, NULL )) XD40H,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_D40H,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.UOM_CD, '' )) UOM_CD_D40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_D40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D40H', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_D40H,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.RATE_COMPONENT_AMT, NULL )) XD45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_D45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.UOM_CD, '' )) UOM_CD_D45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_D45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D45', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_D45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.RATE_COMPONENT_AMT, NULL )) XD48,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_D48,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.UOM_CD, '' )) UOM_CD_D48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_D48,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D48', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_D48,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.RATE_COMPONENT_AMT, NULL )) XR20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_R20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_R20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_R20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.UOM_CD, '' )) UOM_CD_R20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_R20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R20', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_R20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.RATE_COMPONENT_AMT, NULL )) XR40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_R40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_R40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_R40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.UOM_CD, '' )) UOM_CD_R40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_R40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_R40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.RATE_COMPONENT_AMT, NULL )) XR45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_R45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_R45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_R45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.UOM_CD, '' )) UOM_CD_R45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_R45,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R45', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_R45,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.RATE_COMPONENT_AMT, NULL )) XRD20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_RD20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_RD20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_RD20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.UOM_CD, '' )) UOM_CD_RD20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_RD20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD20', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_RD20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.RATE_COMPONENT_AMT, NULL )) XRD40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_RD40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_RD40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_RD40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.UOM_CD, '' )) UOM_CD_RD40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_RD40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'RD40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_RD40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.RATE_COMPONENT_AMT, NULL )) XH40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_H40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_H40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_H40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.UOM_CD, '' )) UOM_CD_H40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_H40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'H40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_H40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.RATE_COMPONENT_AMT, NULL )) XFR20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_FR20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_FR20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_FR20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.UOM_CD, '' )) UOM_CD_FR20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_FR20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR20', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_FR20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.RATE_COMPONENT_AMT, NULL )) XFR40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_FR40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_FR40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_FR40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.UOM_CD, '' )) UOM_CD_FR40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_FR40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'FR40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_FR40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.RATE_COMPONENT_AMT, NULL )) XOT20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_OT20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_OT20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_OT20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.UOM_CD, '' )) UOM_CD_OT20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_OT20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT20', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_OT20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.RATE_COMPONENT_AMT, NULL )) XOT40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_OT40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_OT40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_OT40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.UOM_CD, '' )) UOM_CD_OT40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_OT40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'OT40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_OT40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.RATE_COMPONENT_AMT, NULL )) XTK20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_TK20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_TK20,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_TK20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.UOM_CD, '' )) UOM_CD_TK20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_TK20,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK20', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_TK20,
SUM(NULL) XCOMP_AMT1,
0 RATE_ID_NBR1,
'' RATE_BASIS_CD1,
0 RATE_SOURCE_ID_NBR1,
'' UOM_CD1,
'' UOM_TYPE_CD1,
'' AMENDMENT_RATE_ACTION_CD1,
SUM(NULL) XCOMP_AMT2,
0 RATE_ID_NBR2,
'' RATE_BASIS_CD2,
0 RATE_SOURCE_ID_NBR2,
'' UOM_CD2,
'' UOM_TYPE_CD2,
'' AMENDMENT_RATE_ACTION_CD2,
SUM(NULL) XCOMP_AMT3,
0 RATE_ID_NBR3,
'' RATE_BASIS_CD3,
0 RATE_SOURCE_ID_NBR3,
'' UOM_CD3,
'' UOM_TYPE_CD3,
'' AMENDMENT_RATE_ACTION_CD3,
SUM(NULL) XCOMP_AMT4,
0 RATE_ID_NBR4,
'' RATE_BASIS_CD4,
0 RATE_SOURCE_ID_NBR4,
'' UOM_CD4,
'' UOM_TYPE_CD4,
'' AMENDMENT_RATE_ACTION_CD4,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.RATE_COMPONENT_AMT, NULL )) XR40H,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_R40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_R40H,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_R40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.UOM_CD, '' )) UOM_CD_R40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_R40H,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'R40H', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_R40H,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.RATE_COMPONENT_AMT, NULL )) XTK40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_TK40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_TK40,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_TK40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.UOM_CD, '' )) UOM_CD_TK40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_TK40,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'TK40', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_TK40,
RLT.PRINT_SEQ,
DECODE ( TO_CHAR ( RT.rate_effective_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.amendment_effective_dt, RT.rate_effective_dt ) actual_eff_date,
DECODE ( TO_CHAR ( RT.rate_expiration_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.CURR_AGREEMENT_EXPIRATION_DT, RT.rate_expiration_dt ) actual_exp_date,
RT.ORIG_INLAND_TRANS_MODE_CD,
RT.DEST_INLAND_TRANS_MODE_CD,
RT.SERVICE_CD,
RT.REF_EQUIPMENT_TYPE_SIZE_CD,
RT.IN_OUT_GAUGE_CD,
RT.PER_GT_DATE_FLG,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.RATE_COMPONENT_AMT, NULL )) X53,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.RATE_BASIS_CD )) RATE_BASIS_CD_53,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.UOM_CD, '' )) UOM_CD_53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.UOM_TYPE_CD )) UOM_TYPE_CD_53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, '53', RT.AMENDMENT_RATE_ACTION_CD )) AMENDMENT_RATE_ACTION_CD_53,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.RATE_COMPONENT_AMT, NULL )) XD53,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.RATE_ID_NBR, NULL )) RATE_ID_NBR_D53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.RATE_BASIS_CD, '' )) RATE_BASIS_CD_D53,
SUM ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.RATE_SOURCE_ID_NBR, NULL )) RATE_SOURCE_ID_NBR_D53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.UOM_CD, '' )) UOM_CD_D53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.UOM_TYPE_CD, '' )) UOM_TYPE_CD_D53,
MAX ( DECODE ( RT.EQUIPMENT_TYPE_SIZE_CD, 'D53', RT.AMENDMENT_RATE_ACTION_CD, '' )) AMENDMENT_RATE_ACTION_CD_D53
FROM APL_PRICING.RATE_LOCATION_TEMP RLT,
APL_PRICING.RATE_AGREEMENT_COMMODITY CM,
APL_PRICING.COMMODITY_RATE CR,
APL_PRICING.RATE_AGREEMENT_AMENDMENT AMD1,
APL_PRICING.RATE_AGREEMENT_AMENDMENT AMD2,
APL_PRICING.RATE RT
WHERE RT.RATE_AGREEMENT_NBR = :rate_agreement_nbr
AND AMD1.RATE_AGREEMENT_NBR = :rate_agreement_nbr
AND AMD1.AMENDMENT_NBR <= :amendment_nbr
AND RT.AMENDMENT_NBR = AMD1.AMENDMENT_NBR
AND RT.RATE_COMPONENT_CD IN (:rate_component_cd)
AND DECODE ( TO_CHAR ( RT.rate_expiration_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.CURR_AGREEMENT_EXPIRATION_DT, RT.rate_expiration_dt ) >= :amendment_effective_dt
AND RT.RATE_ID_NBR = CR.RATE_ID_NBR
AND CR.COMMODITY_BLIND_KEY_NBR = CM.COMMODITY_BLIND_KEY_NBR
AND CM.RATE_AGREEMENT_NBR = :rate_agreement_nbr
AND AMD2.RATE_AGREEMENT_NBR = :rate_agreement_nbr
AND AMD2.AMENDMENT_NBR <= :amendment_nbr
AND CM.AMENDMENT_NBR = AMD2.AMENDMENT_NBR
AND DECODE ( TO_CHAR ( CM.COMMODITY_EXPIRATION_DT, 'MM/DD/YYYY' ), '01/01/1900', AMD2.CURR_AGREEMENT_EXPIRATION_DT, CM.COMMODITY_EXPIRATION_DT ) >= :amendment_effective_dt
AND RT.RATE_BASIS_CD = 'PC'
AND CR.COMMODITY_BLIND_KEY_NBR = :commodity_blind_key_nbr
AND (( RT.DEST_PRICING_LOCATION_GROUP_CD IS NULL
AND RT.DESTINATION_LOCATION_CD IS NOT NULL
AND RT.DESTINATION_LOCATION_CD = RLT.LOCATION_CD
AND RLT.GOVERNING_BODY_CD = :governing_body /*ss */)
OR ( RT.DESTINATION_LOCATION_CD IS NULL
AND RT.DEST_PRICING_LOCATION_GROUP_CD IS NOT NULL
AND UPPER ( RT.DEST_PRICING_LOCATION_GROUP_CD ) NOT LIKE 'GROUP%'
AND RT.DEST_GOVERNING_BODY_CD = RLT.GOVERNING_BODY_CD
AND RT.DEST_PRICING_LOCATION_GROUP_CD = RLT.PRICING_LOCATION_GROUP_CD
AND RLT.LOCATION_CD = ' ' )
OR ( RT.DESTINATION_LOCATION_CD IS NULL
AND RT.DEST_PRICING_LOCATION_GROUP_CD IS NOT NULL
AND UPPER ( RT.DEST_PRICING_LOCATION_GROUP_CD ) LIKE 'GROUP%'
AND RT.DEST_GOVERNING_BODY_CD = RLT.GOVERNING_BODY_CD
AND RT.DEST_PRICING_LOCATION_GROUP_CD = RLT.PRICING_LOCATION_GROUP_CD
AND RLT.LOCATION_CD = ' ')
OR ( RT.DESTINATION_LOCATION_CD IS NULL
AND RT.DEST_PRICING_LOCATION_GROUP_CD IS NULL
AND RLT.LOCATION_CD = '_RTDMY' )
OR
( RT.DESTINATION_LOCATION_CD IS NOT NULL
AND RT.DEST_PRICING_LOCATION_GROUP_CD IS NULL
AND NOT EXISTS (SELECT LOCATION_CD FROM APL_PRICING.RATE_LOCATION_TEMP RLT2
WHERE RLT2.LOCATION_CD = RT.DESTINATION_LOCATION_CD
AND RLT2.GOVERNING_BODY_CD = :governing_body /* IDM 03/23/99 */)
AND RLT.LOCATION_CD = '_RTDMY' ))
GROUP BY RT.RATE_AGREEMENT_NBR,
RT.AMENDMENT_NBR,
DECODE ( TO_CHAR ( RT.rate_effective_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.amendment_effective_dt, RT.rate_effective_dt ),
DECODE ( TO_CHAR ( RT.rate_expiration_dt, 'MM/DD/YYYY' ), '01/01/1900', AMD1.CURR_AGREEMENT_EXPIRATION_DT, RT.rate_expiration_dt ),
RT.ORIGINAL_EXPIRATION_DT,
RT.RATE_DELETE_FLG,
RT.RATE_COMPONENT_CD,
RT.VALIDATION_FLG,
RT.RATE_PCT,
RT.RATE_QTY,
RT.RECEIVE_MODE_CD,
RT.DELIVERY_MODE_CD,
RT.INCLUDE_FLG,
RT.DNH_FLG,
RT.SERVICE_MODE_CD,
RT.ORIGIN_GOVERNING_BODY_CD,
RT.ORIGIN_PRICING_LOC_GROUP_CD,
RT.DEST_GOVERNING_BODY_CD,
RT.DEST_PRICING_LOCATION_GROUP_CD,
RT.ORIGIN_LOCATION_CD,
RT.DESTINATION_LOCATION_CD,
RT.ORIGIN_DESCRIPTION_TXT,
RT.DESTINATION_DESCRIPTION_TXT,
RT.APL_PRIMARY_CURRENCY_CD,
RT.DATATIZED_RATE_FLG,
RT.SYSTEM_GENERATED_FLG,
RT.LAST_UPDATE_USER_ID_CD,
RT.ORIGIN_VIA_GOVERNING_BODY_CD,
RT.ORIGIN_VIA_PRICING_LOC_GRP_CD,
RT.ORIGIN_VIA_LOCATION_CD,
RT.DEST_VIA_GOVERNING_BODY_CD,
RT.DEST_VIA_PRICING_LOC_GROUP_CD,
RT.DEST_VIA_LOCATION_CD,
RT.PREPAID_COLLECT_FLG,
CR.COMMODITY_BLIND_KEY_NBR,
RLT.PRINT_SEQ,
RT.ORIG_INLAND_TRANS_MODE_CD,
RT.DEST_INLAND_TRANS_MODE_CD,
RT.SERVICE_CD,
RT.REF_EQUIPMENT_TYPE_SIZE_CD,
RT.IN_OUT_GAUGE_CD,
RT.PER_GT_DATE_FLG