title: Mysql Views issue ( repeated )
body: <p>I am trying to extract a report using MySQL views, but a new row is repeated for each user as shown in the following image </p>
  
  <p>could you please help me to rewrite this query to resolve this issue ? </p>
  
  <pre><code>DROP FUNCTION IF EXISTS adminExportFromDate;
    DROP FUNCTION IF EXISTS adminExportToDate;
    create function adminExportFromDate() returns DATETIME DETERMINISTIC NO SQL return @adminExportFromDate;
    create function adminExportToDate() returns DATETIME DETERMINISTIC NO SQL return @adminExportToDate;
  
    create or replace view admin_export as
       Select  admin.id as id ,CONCAT(admin.first_name," ",admin.last_name) as Name ,
               count(DISTINCT `all_jobs`.`id`)AS all_jobs_count,
               sum( case when `all_jobs`.job_status_id = 25 then 1 else 0 end ) as canceled_jobs_count,
               sum( case when `all_jobs`.job_status_id in (31,30,3) then 1 else 0 end ) as finished_jobs_count,
               0 as deleted_jobs_count
           From admin
               INNER  JOIN job all_jobs on all_jobs.created_by_id = admin.id and all_jobs.created_by_level = \'admin\'
               and `all_jobs`.`request_date` &gt; AdminExportFromDate() AND `all_jobs`.`request_date` &lt; AdminExportToDate()
        group by admin.id
  
        UNION ALL
  
    select admin.id,CONCAT(admin.first_name," ",admin.last_name) as Name,
    0 AS all_jobs_count,
    0 as canceled_jobs_count,
    0 as finished_jobs_count,
    count( deleted_log.id ) as deleted_jobs_count
  
    From admin INNER JOIN deleted_log
        on deleted_log.`type` LIKE \'job\' and data RLIKE CONCAT(\'"created_by_level":"admin","created_by_id":"\',`admin`.`id`,\'"\') and `deleted_log`.`created_at` &gt; AdminExportFromDate() AND `deleted_log`.`created_at` &lt; AdminExportToDate()
        group by admin.id
  </code></pre>
  
  <p>And this is the result of view :</p>
  
  <p><img src="https://i.stack.imgur.com/XJZHC.png" alt="enter image description here"></p>