Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create function korektaCenyNalisnika(idnalesnika int) returns void as
- $$
- declare
- float avg;
- begin
- create temp table times as select id_bazowego_nalesnika as id_nalesnika,count(*) as sztuk from kompozycje group by id_nalesnika;
- select avg(sztuk) into avg from times;
- update bazowe_nalesniki b
- set koszt = case
- when avg<sztuk then koszt*1.05
- else koszt *0.95 end
- from times t
- where t.id_nalesnika = b.id_nalesnika and b.id_nalesnika=idnalesnika;
- drop table times;
- end;
- $$
- language plpgsql;
Add Comment
Please, Sign In to add comment