Unanswered: How to add 2 columns without using a function
I'm new to SQL
I have an employee table with different columns such as name, salary, commission, etc.
I like to select actual salary which means (salary + commission) where some commissions are NULL.
The prof. specifically mentioned not using any functions, i.e. COALESC.
can someone help me on this?
actually he doesn't teach that well. He asks the things he hasn't covered in the class. One other question he asked was about the day of our DOB. I had to search on line for it.
Thanks for the tip, I nee to try this CASE expression. I found it on line as:
1. CASE column_name
2. WHEN condition1 THEN result1
3. WHEN condition2 THEN result2
5. ELSE result
I need to try it out.
by the way, actual_salary is not a column of the table.
The following doesn't work.
WHEN commission IS NULL THEN SELECT Salary AS actual_salary FROM emp
When commission IS NOT NULL THEN SELECT Salary + commission As actual_salary
a searched CASE? hmm
I did find some examples but they don't do arithmetic expressions like I need to be doing in my case. I know the logic, I just don't know the commands!
I want it to do something like this
CASE WHEN commission=NUll THEN Salary=Salary
CASE WHEN commission= NOT NUll THEN Salary=Salary+ commission
not quite, cause I need to have an "actual_salary" somewhere!
Hey I just noticed you're a consultant from Toronto, that's cool
I really like database stuff and I'm seriously thinking to continue on SQL on my Master's
if you think of it, everything depends on databases.