Add calculated columns together.
Greetings,
I am creating a query table. I have two column that are calculated, based on a case statement. In both columns, the result is always a number. I need to ass the two columns together to create a third column. However, it always either gives me an error, or concatenates the two fields together.
I've tried using the convert() function to no avail. How can I add these two calculated columns together to create a third numeric column?
Example...
SELECT
case when TYPE in ('type1', 'type2', 'type3')
then "Net"
else 0
end Gross ,
case when TYPE in ('type4', 'type5', 'type6')
then "Net"
else 0
end Expenses,
-- the following results in a concatenation rather than addition
(case when TYPE in ('type1', 'type2', 'type3')
then "Net"
else 0
end)
+
(case when TYPE in ('type4', 'type5', 'type6')
then "Net"
else 0
end) Net,
FROM "Transactions"