<?php   include_once('../../config/db.php');   include_once('../../config/check2.php');
             
  


$query = "                 SELECT COUNT(*) ans,e.name dname , e.name cname,d.branch, d.product product  FROM
                              ( 
                                            SELECT a.*,MONTH(a.date)mymonth, year(a.date) myyear   FROM  crmlead a 
                      
                                            
                              )d LEFT JOIN crmproduct e ON d.product=e.id 
										             GROUP BY d.product  
                               ORDER BY d.product asc
                               
                    ";

$result = $conn->query($query);
$data = [];
		    foreach ($result as $row) {
		                                $data[] = $row;
		                             }

print json_encode($data);

///MONTH(b.date)

