var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: how to work out length of employement?
hi! i have table called employee. in there i have the fields
i want to work out the lenghtOfEmployement but when i try the code
it gives me an error 'column not allowed'. how can i work out the lenghtOfEmployement within that field.
insert into employee values(
1001, 7777, 'John', 'Smith', '12', 'Woodcock', 'Cheshunt', 'Hertfordshire',
'ER3RR3', '01233433456', '12-03-1999',
100101); round(sysdate - startdate),
Don't INSERT, UPDATE!
However, storing computed values in a table is not a very good idea. "Number of days" is about to change every day and there's really no purpose in doing that.
UPDATE employee SET
lengthOfEmployement = ROUND(SYSDATE - startdate);
ok thanks. but have u got any ideas how i could improve this then? can i have it calculate only the months then. this would be more sensible.
No, it wouldn't.
This information isn't worth much. What would you do with it in a table, anyway? Select it and display in a report? If so, calculate it when the report is run. Otherwise, you'd first have to update a table (which might take a while if a table is large) and then display the result in a report.
Once again: do not store such information in a table - calculate it whenever needed.
Littlefoot is totally correct. When you need the years of service (for example), simply compute it during the select.
SELECT FLOOR(MONTHS_BETWEEN(SYSDATE,STARTDATE))/12) YEARS
You do not need a parachute to skydive. You only need a parachute to skydive twice.