1:create view bbps_vwAdjustmentSplits as 2:select 3: adjustmentSequence, 4: 5: giftLinkId, 6: 7: giftsplitid, 8: giftid, 9: originalGiftId, 10: adjustmentid, 11: amount, 12: fundid, 13: campaignid, 14: appealid, 15: packageid, 16: sequence, 17: import_id 18: 19:from 20:( 21: ( 22: select 23: adjustmentSequence, 24: giftLinkId, 25: giftsplitid, 26: giftid, 27: originalGiftId, 28: adjustmentid, 29: amount, 30: fundid, 31: campaignid, 32: appealid, 33: packageid, 34: sequence, 35: import_id 36: from 37: bbps_vwPreAdjustmentSplits 38: ) 39: 40: union 41: 42: ( 43: select 44: adjustmentSequence, 45: giftLinkId, 46: giftsplitid, 47: giftid, 48: originalGiftId, 49: adjustmentid, 50: amount, 51: fundid, 52: campaignid, 53: appealid, 54: packageid, 55: sequence, 56: import_id 57: from 58: bbps_vwNegativeAdjustmentSplits 59: ) 60: 61: union 62: 63: ( 64: select 65: 0 as adjustmentSequence, 66: giftId as giftLinkId, 67: giftsplitid, 68: giftid, 69: giftId as originalGiftId, 70: adjustmentid, 71: amount, 72: fundid, 73: campaignid, 74: appealid, 75: packageid, 76: sequence, 77: import_id 78: from 79: giftSplit 80: where 1=1 81: and not (giftId is null or not giftId = adjustmentId) 82: ) 83:) as unionedSplits 84: 85: 86: