I am creating a MySQL View table, so my code looks something like this so far:
CREATE VIEW `myview`
AS SELECT
(do some stuff here) AS `Revenue1`,
(do some more here) AS `Revenue2`
FROM ...
Now I want to add a column that is the sum of both of those fields, so I tried this:
CREATE VIEW `myview`
AS SELECT
(do some stuff here) AS `Revenue1`,
(do some more here) AS `Revenue2`,
(`Revenue1` + `Revenue2`) AS `TotalRevenue`
FROM ...
but this resulted in an error saying that the Revenue1 field was unknown. How can I add the two fields and get the result as a new column?
you must repeat the stuff as:
or create a second view as: