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,
desk_details.shortcut,
repetition,
news,
imports,
today,
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 ,
        IFNULL(SUM(repetition),0) AS repetition,
        IFNULL(SUM(news),0) AS news,
        IFNULL(SUM(imports),0) AS imports,
        IFNULL(SUM(olds),0) AS olds,
        IFNULL(SUM(today),0) AS today
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