sql >> Base de Datos >  >> RDS >> Mysql

Recuperar el número de filas con un valor particular después de filtrar la consulta a través del selector de fechas

$sql = "SELECT
            sum(case when status = 'D' then 1 else 0 end) AS Draft,
            sum(case when status = 'L' then 1 else 0 end) AS Let,
            id
        FROM `crm_listings`  
        WHERE added_date BETWEEN '" . $st_date . "' AND '".$end_date."'
        ORDER BY `added_date` DESC";
$response = count($this->db->query($sql));
echo $response;

O

echo $response->num_rows();