select * from (
SELECT 
`desk_details`.`desk_id` AS `desk_id`,
`desk_details`.`desk_code` AS `desk_code`,
`desk_details`.`user_id` AS `user_id`,
`desk_details`.`parent_desk` AS `parent_desk`,
IFNULL(`desks_Repetition`.`countRepetition`, 0) AS `Repetition`,
IFNULL(`desks_Repetition`.`countNews`, 0) AS `News`,
IFNULL(`desks_Repetition`.`countimports`, 0) AS `imports`,
IFNULL(`desks_Repetition`.`counttoDay`, 0) AS `toDay`,
IFNULL(`desks_Repetition`.`countOlds`, 0) AS `Olds`
from (select * from desks where parent_desk = '{parent_desk}' and user_id = '{user_id}') desk_details
left join (
    select desk_details.desk_id as desk_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
(select * from desks where parent_desk = '{parent_desk}' and user_id = '{user_id}') desk_details
left join
`cards_data_base` on desk_details.user_id = cards_data_base.user_id 
WHERE
    `cards_data_base`.`tree` LIKE concat('%',desk_details.desk_id,'%')
    group by desk_id
    )
    desks_Repetition on desk_details.desk_id = desks_Repetition.desk_id) e_desk_parent_data