Fat Budapest Fat Budapest - 4 months ago 7
SQL Question

SQL query to combine 2 columns possible?

This query is not what we need. the 2 ENT# need to be IHGRC# if = adent# + adsfx. that is how they store in the app. Can that be combined that way? For example
HRGRC# = 2558807001

adent# = 2558807
adsfx# = 001

this would be a match.

SELECT OEINH2.IHDOCD, OEINH2.IHINV#, OEINH2.IHGRC#, ADRES1.ADINTA, ADRES1.ADENT#, ADRES1.ADSFX#
FROM ASTDTA.OEINH2
INNER JOIN ASTDTA.ADRES1 ON OEINH2.IHENT#=ADRES1.ADENT#

ORDER BY OEINH2.IHINV#

Answer

If you just want to concatenate the values, you can use concat():

select concat(adent#, adsfx) as HRGRC#

or use the concatenation operator:

select(adent# || adsfx) as HRGRC#
Comments