How to pass the input parameters to dynamic Pivot stored procedure
I'm passing input parameter in_branchId into pivot Mysql Query 

DROP PROCEDURE IF EXISTS `leavemanagement`.`SP_ViewAttendance` $$
    CREATE DEFINER=`root`@`localhost` PROCEDURE `SP_ViewAttendance`(

              IN in_attendance_start_date DATETIME,
        IN in_attendance_end_date DATETIME,
        In in_branchId varchar(100)
    )
    BEGIN
          SET SESSION group_concat_max_len = 1000000000;

          SET @sql = NULL ;
      SELECT
        GROUP_CONCAT(
          DISTINCT CONCAT(
            'max(CASE WHEN attendance.date = ''',
            DATE_FORMAT(DATE, '%Y-%m-%d'),
            ''' THEN coalesce(p.present, '''') END) AS `',
            DATE_FORMAT(DATE, '%Y-%m-%d'),
            '`'
          )
        ) INTO @sql
      FROM
        calendar ,attendance
      WHERE DATE &gt;= in_attendance_start_date
        AND DATE &lt;= in_attendance_end_date
          AND attendance.branch_id = in_branchId;




      SET @sql = CONCAT(
        ' SELECT  ', @sql,'
            from
                (
                   select c.date,  a.user_id ,a.user_name,a.attendance_id,a.attendance_date
                     from calendar c
                     cross join attendance a
                ) attendance
                left join attendance  p
                  on attendance.user_id= p.user_id
                  and attendance.date = p.attendance_date

               where

                      attendance.date&gt;= date
                  and attendance.date &lt;= date
                  AND p.branch_id = ',in_branchId,' GROUP BY attendance.user_id') ;


    PREPARE stmt FROM @sql;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;