Question

This sql is working but the second substring, is the order num. For these we need to add a '0' at the end, to make it 8 pos now. Not sure how to do this in SQL.

SELECT                                                             
  ALL       SUBSTR(UANOTL,1,4) AS CODE1, SUBSTR(UANOTL,5,7) AS ORDER#, 
            UAATHN, UANOTD                                                 
  FROM      ASTDTA.NOTEH1 T01                                      
  WHERE     SUBSTR(UANOTL,1,4) = 'REM '                            
Was it helpful?

Solution

You need the concatenation operator:

SELECT ALL 
  SUBSTR(UANOTL,1,4) AS CODE1, 
  SUBSTR(UANOTL,5,7) || '0' AS ORDER#, 
  UAATHN, UANOTD
FROM ASTDTA.NOTEH1 T01
WHERE SUBSTR(UANOTL,1,4) = 'REM '

OTHER TIPS

you just put an & operator before the string and the 0 you want to add

so 0 in front would be

select ('0' & ORDER#)

and at the end would be

select (ORDER# & '0')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top