简体   繁体   中英

SQL Calculated field selected values

I have a SQL View with columns IDX, DATE, SIGNAL, VALUE We have SIGNAL1 to SIGNAL10 What I want is that on Daily basis a computed column which is calculated as follows:

Compval= SIGNAL7*SIGNAL8-SIGNAL9

Other columns retain the original values

How to do this?

You can create another view or just add this column to your view:

create view v_view as
    select v.*, (SIGNAL7*SIGNAL8-SIGNAL9) as CompVal
    from first_view v;

在MS SQL Server中,您可以添加如下所示的计算列

    ALTER table TableA ADD compVal AS SIGNAL7*SIGNAL8-SIGNAL9 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM