Join Various Results

0

Someone knows in sql server theme, how to join a result that gives me from 3 rows to a single row I'm using this query but it does not attach them to me in a single result, something when I do an XML result but with some function .

SELECT   ERROR + CAST(Campo1 AS nvarchar) + 'Pos' + CAST(campo2 AS nvarchar)+ 'Pro'+CAST(campo3 AS nvarchar) 
FROM Tabla T1 
INNER JOIN tabla2 ON campo1 = campo2 AND campo1 = campo2
    
asked by Abel Ramirez 17.01.2018 в 17:24
source

2 answers

1

You can use the Concat Function

    SELECT CONCAT ( ERROR,  CAST(Campo1 AS nvarchar) , 'Pos', CAST(campo2 AS nvarchar), 'Pro',CAST(campo3 AS nvarchar) ) AS Result FROM Tabla T1 
INNER JOIN tabla2 ON campo1 = campo2 AND campo1 = campo2
    
answered by 17.01.2018 в 17:34
0

The standard way in SQL is:

SELECT COALESCE(field1, '') || COALESCE(field2, '') || COALESCE(field3, '') FROM table1 ...
    
answered by 17.01.2018 в 17:31