如何避免表中的重复值来过滤php中的列表

I have a renewed list and its out of date list is also stored in a table. But, I search the enddate, there should be shows both active and disabled state. I want to show only the active state in list. what can I do?

function client_list_json($clientplan_enddate='', $plan='') {
    $aColumns       = array("sl","client_name","plan_name","clientplan_startdate","clientplan_enddate","client_username","client_email","client_phone","clientplan_status","clientplan_id");

    $aQuery         = "client_id as sl,client_name,plan_name,DATE_FORMAT(clientplan_startdate,'%d-%m-%Y') as clientplan_startdate,DATE_FORMAT(clientplan_enddate,'%d-%m-%Y') as clientplan_enddate,client_username,client_email,client_phone,(CASE clientplan_status WHEN '1' THEN ' <span class=\"label label-success\">Active</span>' WHEN '0' THEN '<span class=\"label label-important\">Disable</span>' ELSE '' END) as clientplan_status,clientplan_id";
    $sIndexColumn   = "clientplan_id";


    $sTable="client join clientplan on client.client_id=clientplan.clientplan_clientid left join plan on clientplan.clientplan_planid=plan.plan_id ";  


    $sLimit         = "";
    $iDisplayStart  = isset($_GET['iDisplayStart']) ? $_GET['iDisplayStart'] : 0;
    $iDisplayLength = isset($_GET['iDisplayLength']) ? $_GET['iDisplayLength'] : 0;

    if (isset($_GET['iDisplayStart']) && $iDisplayLength != '-1') {
        $sLimit = " LIMIT " . $this->db->escape($iDisplayStart) . ", " . $this->db->escape($iDisplayLength);
    }
    $sOrder = "";
      if (isset($_GET['iSortCol_0'])) {
        $sOrder = " ORDER BY  ";
        for ($i = 0; $i < intval($_GET['iSortingCols']); $i++) {
            if ($_GET['bSortable_' . intval($_GET['iSortCol_' . $i])] == "true") {
                $sOrder .= $aColumns[intval($_GET['iSortCol_' . $i])] . "
                " . $_GET['sSortDir_' . $i] . ", ";
            }
        }
        $sOrder = substr_replace($sOrder, "", -2);
        if ($sOrder == "ORDER BY") {
            $sOrder = "";
        }
    }
    $sSearch    = isset($_GET['sSearch']) ? $_GET['sSearch'] : "";
    $sWhere = "WHERE 1 ";
    if ($sSearch != "") {
        $sWhere .= "AND (";

        for ($i = 0; $i < count($aColumns); $i++) {

            //  Search Columns Filitered
            if ($i == 1 || $i == 2) {
                $sWhere .= $aColumns[$i] . " LIKE '%" . $_GET['sSearch'] . "%' OR ";
            }
        }
        $sWhere = substr_replace($sWhere, "", -3);
        $sWhere .= ')';
    }


    $client_enddate_filter=" ";

   if(  $clientplan_enddate!=''){

   $clientplan_enddate= $this->db->escape($clientplan_enddate);
   $client_enddate_filter.="AND clientplan_enddate=$clientplan_enddate ";

   }

   $plan_filter=" ";

   if( $plan!=''&& $plan!=-1){

   $plan= $this->db->escape($plan);
   $plan_filter.="AND plan_name=$plan  ";

   }

   $sQuery     = " SELECT SQL_CALC_FOUND_ROWS $aQuery FROM $sTable $sWhere $plan_filter GROUP BY client_id HAVING $client_enddate_filter $sOrder  $sLimit ";


    $rResult    = $this->db->query($sQuery);
    $iResult    = $this->db->query('select FOUND_ROWS() AS found_rows');
    $iFilteredTotal = $this->db->row($iResult)->found_rows;
    $sQuery     = " SELECT $sIndexColumn FROM   $sTable WHERE 1 ";
    $aResultTotal = $this->db->query($sQuery);
    //var_dump($aResultTotal);
    $iTotal = $this->db->num_rows($aResultTotal);

    $sEcho = isset($_GET['sEcho']) ? $_GET['sEcho'] : "";
    $output = array(
        "sEcho" => intval($sEcho),
        "iTotalRecords" => $iTotal,
        "iTotalDisplayRecords" => $iFilteredTotal,
        "aaData" => array()
    );

    $sl_count = $iDisplayStart + 1;
    foreach ($this->db->fetch_object($rResult) as $aRow) {

        $row = array();

        for ($i = 0; $i < count($aColumns); $i++) {
            if ($aColumns[$i] == 'sl') {
                $row[] = $sl_count;
            }


       else {
                $row[] = $aRow->$aColumns[$i];
            }
        }
        $output['aaData'][] = $row;

        $sl_count++;
    }

    return json_encode($output);

}