I believe you need to use this query,
SELECT ([Basic Salary] + HRA + [TA&DA]) AS 'Total'
FROM Employee
WHERE Employee_ID = @SalID;
Application of an aggregate function (
SUM()
in this case) makes little sense, why would you spread the
Basic Salary
of an employee all over the table, and then
group it? If you wanted to get a grouping of the values, then maybe
SUM()
part makes sense, but
WHERE
query is inappropriate for a group as you might want to apply something like,
WHERE Basic Salary > 1000
etc.
Secondly, please name the tables in a better way—TA_DA would make more sense. Similar for Basic_Salary, avoid spacing, and special characters/names. You might know what you did, but the other DBA(s) would always be up for a challenge to break things. :-)
Check out
this thread[
^] to learn about other ways in which you can get the sum of columns for a record.