CREATE OR REPLACE PROCEDURE 
    Salaries
BEGIN
    SELECT 
        k.keyword AS keyword,
        AVG( v.salary ) AS average_salary
    FROM 
        vacancy v,
        keyword k,
        vacancy_keyword vk
    WHERE 
        vk.vacancy_id = v.id
    AND
        vk.keyword_id = k.id
    AND
        v.start_date >= DATE_SUB( NOW(), INTERVAL 1 YEAR )
    GROUP BY
        k.id
    ORDER BY
        k.keyword ASC
    ;
END