I have a table as shown below
declare @Location Table([state] nvarchar(30) null,city nvarchar(30) null) Insert Into @Location Values('California','San Francisco') Insert Into @Location Values('California',null) Insert Into @Location Values('California','Orange County') Insert Into @Location Values('California',null)
And a select statement as shown below
select [state],city,[state] as CurrentState, case when city is null then 'Sacramento' else city end as CurrentCity from @Location
The output is as follows
I want a fifth column titled Address which gives me the sum of the columns CurrentState and CurrentCity Like thus:
Address California, San Francisco California, Sacramento California, Orange County California, Sacramento
Is this possible?
I've already tried CurrentState+', '+CurrentCity. It doesn't work
Aucun commentaire:
Enregistrer un commentaire