kresimirgalic
07/12/2022, 5:53 PMproject_time_entries
with columns duration
in minutes, and table `project_members`where i have column `cost_rate`which is hourly rate of employee.
so what i want is to join those two tables, calculate all durations for this month and get income.
this is what i trie and it returns me duplicated rows
create or replace function get_time_entries_income (
start_date text, end_date text
)
returns table (
duration integer,
cost_rate integer
)
language plpgsql
as $$
begin
return query
select pt.duration, p.cost_rate
from project_time_entries pt
inner join project_members p
on pt.member_id = p.member_id
where work_date between start_date and end_date;
end
$$;