SELECT
    `b`.`man_power` AS `man_power`,
    `b`.`retail_man_power` AS `retail_man_power`,
    `b`.`region` AS `region`,
    `b`.`branch_code` AS `branch_code`,
    `b`.`id` AS `id`,
    `v1`.`sum1` AS `sum1`,
    `v2`.`sum2` AS `sum2`,
    `v3`.`sum9` AS `sum9`,
    `v4`.`sum3` AS `sum3`
FROM
    (
        (
            (
                (
                    `satgurucrm_shailesh`.`mst_branch` `b`
                JOIN(
                    SELECT
                        `mb`.`id` AS `id`,
                        SUM(`vag`.`potential_amount`) AS `sum1`
                    FROM
                        (
                            `satgurucrm_shailesh`.`mst_branch` `mb`
                        JOIN `satgurucrm_shailesh`.`vw_account_grid` `vag`
                        ON
                            (
                                (
                                    (`mb`.`region` = `vag`.`region_id`) AND(
                                        `mb`.`branch_code` = `vag`.`branch_code`
                                    )
                                )
                            )
                        )
                    WHERE
                        (
                            (
                                `vag`.`lead_type` IN('NCA-Corporate', 'NCA-PNW', 'NCA-GPNW')
                            ) AND(`vag`.`account_type` = 'NCA') AND(`vag`.`status` = 'Converted')
                        )
                    GROUP BY
                        `mb`.`id`
                ) `v1`
            ON
                ((`b`.`id` = `v1`.`id`))
                )
            JOIN(
                SELECT
                    `mb`.`id` AS `id`,
                    SUM(`vag`.`visa_potential_amount`) AS `sum2`
                FROM
                    (
                        `satgurucrm_shailesh`.`mst_branch` `mb`
                    JOIN `satgurucrm_shailesh`.`vw_account_grid` `vag`
                    ON
                        (
                            (
                                (`mb`.`region` = `vag`.`region_id`) AND(
                                    `mb`.`branch_code` = `vag`.`branch_code`
                                )
                            )
                        )
                    )
                WHERE
                    (
                        (
                            `vag`.`lead_type` IN('NCA-Corporate', 'NCA-PNW', 'NCA-GPNW')
                        ) AND(`vag`.`account_type` = 'NCA') AND(`vag`.`status` = 'Converted')
                    )
                GROUP BY
                    `mb`.`id`
            ) `v2`
        ON
            ((`b`.`id` = `v2`.`id`))
            )
        JOIN(
            SELECT
                `mb`.`id` AS `id`,
                SUM(`vag`.`visa_potential_amount`) AS `sum9`
            FROM
                (
                    `satgurucrm_shailesh`.`mst_branch` `mb`
                JOIN `satgurucrm_shailesh`.`vw_account_grid` `vag`
                ON
                    (
                        (
                            (`mb`.`region` = `vag`.`region_id`) AND(
                                `mb`.`branch_code` = `vag`.`branch_code`
                            )
                        )
                    )
                )
            WHERE
                (
                    (`vag`.`lead_type` = 'NCA-SME') AND(`vag`.`account_type` = 'NCA') AND(`vag`.`status` = 'Converted')
                )
            GROUP BY
                `mb`.`id`
        ) `v3`
    ON
        ((`b`.`id` = `v3`.`id`))
        )
    JOIN(
        SELECT
            `mb`.`id` AS `id`,
            SUM(`vag`.`car_potential_amount`) AS `sum3`
        FROM
            (
                `satgurucrm_shailesh`.`mst_branch` `mb`
            JOIN `satgurucrm_shailesh`.`vw_account_grid` `vag`
            ON
                (
                    (
                        (`mb`.`region` = `vag`.`region_id`) AND(
                            `mb`.`branch_code` = `vag`.`branch_code`
                        )
                    )
                )
            )
        WHERE
            (
                (
                    `vag`.`lead_type` IN('NCA-Corporate', 'NCA-PNW', 'NCA-GPNW')
                ) AND(`vag`.`account_type` = 'NCA') AND(`vag`.`status` = 'Converted')
            )
        GROUP BY
            `mb`.`id`
    ) `v4`
ON
    ((`b`.`id` = `v4`.`id`))
    )