I have a database table
with name
, address
, and monthly account expense
as column information for every single month.
I want to add expenses from month1
to month12
data of an accounts
table but it is in varchar
data type, I want to convert it into float
data type and also use a logical expression in the query that gets the SUM
of all the expenses (month 1
+ month 2
+...month12
) should be greater than 10,000
.
But I am not able to solve this problem as the query is not working and am getting errors
Kindly check this query and let me know of any changes
SELECT name ,address ,CAST(([month1] + [month2]...[month12] AS float) AS 'total expense' FROM Accounts_Table WHERE name LIKE 'a%' GROUP BY name, address, 'total expense' HAVING 'total expense' > 10000
Some pointers will be great to work around this problem.