Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

newbie SQL Question regarding computed columns

Tags:

sql

I have a table with columns Q1 and Q2 say. I now want to define a view such that I have three columns in in Q1 Q2 and H1 such that each entry in H1 is the sum of corresponding entries Q1 and Q1

How can I do this as as SQL Query?

Thanks

like image 951
Rahul Avatar asked Nov 22 '25 09:11

Rahul


2 Answers

I wouyld try this :

CREATE VIEW Q1Q2H1 AS
SELECT Q1,Q2,Q1+Q2 as H1
FROM Table
like image 173
LaGrandMere Avatar answered Nov 24 '25 23:11

LaGrandMere


CREATE VIEW ComputedColumn AS
SELECT Q1, Q2, Q1 + Q2 AS H1
  FROM myTable
like image 21
Neil Knight Avatar answered Nov 24 '25 23:11

Neil Knight



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!