DROP VIEW IF EXISTS pms_rate_view;
CREATE VIEW pms_rate_view(
    editorTotalRate,
    pmTotalArticleScoring,
    editor_id
) as
SELECT
        (
            COALESCE(editor_puntuality_rate.rate, 0) + COALESCE(editor_attitude_rate.rate, 0) + COALESCE(editor_quality_rate.rate, 0)
        ) AS editorTotalRate,
        COALESCE(
            total_article_scoring_pm_view.total_scoring,
            0
        ) AS pmTotalArticleScoring,
        editors_view.id AS editor_id
    FROM
        editors_view
    LEFT JOIN user ON editors_view.user_id = user.id
    LEFT JOIN scoring_puntuality_rate_view editor_puntuality_rate ON
        (
            editors_view.user_id = editor_puntuality_rate.user_id
        ) AND(
            editor_puntuality_rate.participant_type = 2
        )
    LEFT JOIN scoring_attitude_rate_view editor_attitude_rate ON
        (
            editors_view.user_id = editor_attitude_rate.user_id
        ) AND(
            editor_attitude_rate.participant_type = 2
        )
    LEFT JOIN scoring_quality_rate_view editor_quality_rate ON
        (
            editors_view.user_id = editor_quality_rate.user_id
        ) AND(
            editor_quality_rate.participant_type = 2
        )
    LEFT JOIN total_article_scoring_pm_view ON total_article_scoring_pm_view.user_id = USER.id;