Well, I can't get my head around that particular function.
I want to calculate and then return the total amount of hours assigned for a given stage_no.
I got confused. Do I have to use COUNT(*)?
CREATE OR REPLACE FUNCTION total_numbers_hours(hours NUMBER, stage_no NUMBER) RETURN NUMBER IS return_val NUMBER; BEGIN SELECT COUNT(*) INTO return_val FROM employees a, stage s WHERE s.stage_id = t.stage_id AND t.task_id = a.task_id AND estimated_hours = hours AND stage_id = stage_no RETURN return_val; END;
And this is my statement:
SELECT s.stage_id, t.task_id, a.employee_no, total_numbers_hours(a.estimated_hours, s.stage_id) FROM stage s, task t, employees a WHERE s.stage_id = t.stage_id AND t.task_id = a.task_id
I am working on it now, so I will update it, as I was typing it I figured out that I messed it up completely. I will be glad if any of you stop and just throw me some thoughts or something. Thank you, guys.
P.S. Oh, yeah, just wanted to ask about my joins, if I did them right.
I am trying to connect 3 tables
STAGE table Stage_id(primary key) stage_no
Task table task_id(primary key) task_no
Employees table employees_no(primary) task_id estimated_hours