Created
April 12, 2018 10:19
-
-
Save vegarringdal/0c0a4a0a2a1cb5fb2e27b2a835d11367 to your computer and use it in GitHub Desktop.
sql test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cte_drum as ( | |
| SELECT | |
| A.PROJECT_CODE, | |
| A.DRUNO AS DRUM_NO, | |
| A.CTYPNO, | |
| A.METER_MARKING_YN, | |
| A.ON_DELIVERY, | |
| (NVL(A.LOST,0)+ NVL(A.SCRAPPED, 0)) AS SCRAPPED_LOST, | |
| decode (A.METER_MARKING_YN, 'Y', B.HIGH_LOW, | |
| 'N', B.INSTALLED) | |
| AS PULLED, | |
| NVL(A.ON_DELIVERY,0) - (NVL(decode ( | |
| A.METER_MARKING_YN, | |
| 'Y', B.HIGH_LOW, | |
| 'N', B.INSTALLED),0) | |
| + NVL(A.LOST,0)+ NVL(A.SCRAPPED, 0)) AS LEFT_ON_DRUM | |
| FROM | |
| PACS.J2_DRUREG A | |
| left join cte_used_on_drum B on | |
| a.DRUNO = B.DRUM_NO | |
| ), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment