CREATE VIEW users_data_repetition AS
SELECT
    users.user_id AS user_id,
    ifnull(users_Repetition.countRepetition, 0) AS Repetition,
    ifnull(users_Repetition.countNews, 0) AS News,
    ifnull(users_Repetition.countimports, 0) AS imports,
    ifnull(users_Repetition.counttoDay, 0) AS toDay,
    ifnull(users_Repetition.countOlds, 0) AS Olds
FROM
    users
    LEFT JOIN (
        -- Repetition
        SELECT
            users.user_id AS user_id,
            SUM(cards_data_base.Repetition) AS countRepetition,
            SUM(cards_data_base.News) AS countNews,
            SUM(cards_data_base.imports) AS countimports,
            SUM(cards_data_base.Olds) AS countOlds,
            SUM(cards_data_base.toDay) AS counttoDay
        FROM
            users
            JOIN cards_data_base ON users.user_id = cards_data_base.user_id
        GROUP BY
            users.user_id
    ) users_Repetition ON users.user_id = users_Repetition.user_id
   