Link to home
Start Free TrialLog in
Avatar of Cav IT
Cav ITFlag for South Africa

asked on

Combine Two Fields

Hi

How can I combine the bcClass.Description and bcBrands.Description fields into one field. There will only be a value in on of the two fields.

SELECT        bcGraderings.Aantal AS Qty, bcGraderings.Class AS sClass, bcGraderings.MG AS MassGrp, bcGraderings.Mass, bcGraderings.Product, bcGraderings.ISO AS Salesbrand, bcClass.Description, 
                         bcBrands.Description AS Expr1
FROM            bcGraderings LEFT OUTER JOIN
                         bcBrands ON bcGraderings.ISO = bcBrands.Code LEFT OUTER JOIN
                         bcClass ON bcGraderings.ISO = bcClass.Code
WHERE        (bcGraderings.gDate > '2014-09-01 00:00:00.000')

Open in new window


Here is an example of the data that is returned with the query

Qty      sClass      MassGrp      Mass      Product      Salesbrand      Description      Expr1
1      M      2      14      SA1      M      Group 1      NULL
1      M      1      8,5      SA1      M      Group 1      NULL
1      M      1      11,5      SA0      M      Group 2      NULL
1      M      4      22      SC2      M      Group 2      NULL
1      D      3      16,5      SA2      N      NULL      Class 1
1      D      3      16,8      SA2      N      NULL      Class 2
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

you can use isnull.

select isnull(bcClass.Description, bcBrands.Description) Description
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cav IT

ASKER

Again, Thanks Vitor.