简体   繁体   中英

How do I multiply and add columns?

I basically want to do this function as a new column.

New Column = a1*a2 + b1*b2 + c1*c2

where a1,a2,b1,b2,c1,c2 are all existing columns with numerical values in each cell. Any help would be appreciated

Please check columns a1,a2,b1,b2,c1,c2 has "type" is bigint;

And use QSL:

ALTER TABLE demo.abc ADD COLUMN d bigint;

Update demo.abc set d = abc.a1 * abc.a2 + abc.b1 * abc.b2 + abc.b1*abc.c2;

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