Computed column in SQL View

2019-08-05 16:26发布

My current view produces this kind of output...

Product1 Product2
Jet      Ski
Water    Polo

Could i use a computed column in a view, in order getting results like these?

Product1 Product2 Computed
Jet      Ski      Jet Ski
Water    Polo     Water Polo

2条回答
Melony?
2楼-- · 2019-08-05 17:27

Sure:

select Product1, Product2, Product1 + ' ' + Product2 as [computed]
  from my_table
查看更多
Summer. ? 凉城
3楼-- · 2019-08-05 17:29

Computed columns are defined at the table level, but why not simply concatenate?

SELECT 
    Product1, 
    Product2, 
    Product1 + ' ' + Product2 AS FullProductName 
FROM 
    MyProductTable
查看更多
登录 后发表回答