what does following sql code do?
guys i have seen following code in internet
select round(abs(months_between(sysdate,add_months(hire_date,12*(round((months_between(sysdate,hire_date)/12))))))) from employees
unfortunately there was not enough information if what does it do,i have run this command in my oracle 11.g database,and seen if of numbers,like 6,5,4,7,3,2
5 2 1 1 6 5 2 2 3
like this ,please i know functions,just can't determine it's usage here,what represent this numbers?please help me
Working from the inside out:-
round( (months_between( sysdate, hire_date) /12)
Gets the number of complete years the employee has been employed
add_months( hire_date,12 * (years calculated above )
Gets the date the employee completed n complete years since being employed
round(abs(months_between( sysdate, date employee completed n years )
Gets the number of months till the next full year of employment.
No idea why!