I have used this query to show the results that I want.
It works perfectly, but I have one problem. When the data in the database have thousands or records it becomes slower. I have heard about data massage.
If I massage the data can it perform better?
<?php
public function search($searchterm)
{
    $sql = "
        SELECT 
            CAST(t.date as Date) AS Date, 
            SUM(t.Transaction)+SUM(r.Request) AS allTransaction, 
            SUM(t.Success)+SUM(r.RequestSuccess) AS allSuccess, 
            t.Transaction, 
            t.Success, 
            r.Request, 
            r.RequestSuccess 
        FROM 
            (
            SELECT 
                date, 
                COUNT(DISTINCT no_a) AS Transaction,            
                SUM(t.status = 0) AS Success
            FROM 
                transfer_tx_201503 AS t 
            WHERE 
                CAST(t.date as time) BETWEEN '00:00:00' AND '$searchterm' 
            GROUP BY CAST(date as Date) DESC
            ) AS t 
            JOIN
            (
            SELECT 
                date, 
                COUNT(DISTINCT no_a) AS Request, 
                SUM(r.status = 0) AS RequestSuccess
            FROM 
                request_tx_201503 AS r 
            WHERE 
                CAST(r.date as time) BETWEEN '00:00:00' AND '$searchterm' 
            GROUP BY CAST(date as Date) DESC
            ) AS r
            ON 
                CAST(t.date as date) = CAST(r.date as date)
            GROUP BY 
                Date 
            DESC";
    $q = $this->db->query($sql);
    if($q->num_rows() > 0)
    {
        foreach($q->result() as $row)
        {
            $data[] = $row;
        }
        return $data;
    }
}
 
     
     
     
    