Join columns in one SQL column

Asked

Viewed 6,216 times

2

I have three columns, belonging to the same table in the database, these being: Growth, Financial Autonomy and Rationliquidity; All columns are bit type.

What I need is to group the three fields in one column, that is, if I do:

SELECT IsNull(Crescimento,0) As Crescimento,

IsNull(AutonomiaFinanceira,0) As AutonomiaFinanceira,

IsNull(RacioLiquidez,0) As RacioLiquidez

from Estado

I get the following:

Tabela Obtida

However I want to group these three fields in one column, for example: 000 or 0,0,0.

  • What would be the SGDB?

  • Microsoft SQL Server Management Studio

1 answer

6


You can use the CONCAT:

SELECT 
  CONCAT(
    IsNull(Crescimento,0),'-',
    IsNull(AutonomiaFinanceira,0),'-',
    IsNull(RacioLiquidez,0)
  )
from Estado;

See an example working on SQL Fiddle.

Note: The syntax of CONCAT is different between the SGDBs.

  • It worked, thank you :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.