jaxrpc
asked on
SQL
i have a table employee and i have 2 fields in it
EmployeeID number(8)
Salary number(7,2)
how do i increase the salary by +20 to all employee whose ID is an odd number.
thanks
EmployeeID number(8)
Salary number(7,2)
how do i increase the salary by +20 to all employee whose ID is an odd number.
thanks
ASKER
Yes i do know how to run an update statement
Yes i can formulate an update of a cloumn.
Odd number i would use employeeID % 2 if it is an odd it should give me a non zero.
update Employee set (salary = (select salary from employee where employeeID % 2 <> 0) + 30))
something like this? i tried ..
Yes i can formulate an update of a cloumn.
Odd number i would use employeeID % 2 if it is an odd it should give me a non zero.
update Employee set (salary = (select salary from employee where employeeID % 2 <> 0) + 30))
something like this? i tried ..
ASKER
update Employee set (salary = (select salary from employee where employeeID % 2 <> 0) + 30)) WHERE employeeID %2 <> 0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi i tried your solutioon..but it says % is an invalid character...weird.
because oracle does not know the % as operator (like ms sql server does).
check out the modulus function:
http://www.psoug.org/reference/number_func.html
check out the modulus function:
http://www.psoug.org/reference/number_func.html
small correction: syntax should be:
UPDATE employee
SET salary = salary +30
WHERE ...
UPDATE employee
SET salary = salary +30
WHERE ...
actually, +20 and not +30, as we all meanwhile wrote :-)
there are several elements:
* do you know how to run an update in general?
* do you know how to formulate an update of a column?
* what is an odd number? -> what function/math/formula can you use (depends on the database products, refer to the function list...)
* limit the update to the above clause (odd number)