SQL数据 - 以特定格式编码json

I have php code that I'm using along with sql to get results from a DB base on EA number and ID number to graph them.

<?php   
            $sql=
                ("SELECT D as y,Total as a,PoweredOn as b 
                FROM MasterUsageTable 
                WHERE ID IN 
                (SELECT ID FROM MasterUsageTable
                WHERE EA_Number = '$valueEA' AND D BETWEEN #$valueSDate# AND #$valueEDate#)");

            $rs = odbc_exec($con, $sqlVMs);
            if (!$rs) {
                exit("Enter EA!");
            }
            $data = array();
                while ($row = odbc_fetch_array($rs)){
                    $data[] = $row;
                }           

            echo json_encode($data);
        ?>

At the moment the way I'm getting my results after the json encode is like this:

[{"y":"2015-03-26","a":"16","b":"14"},{"y":"2015-03-26 ","a":"59","b":"12"},{"y":"2015-03-26 ","a":"21","b":"5"},{"y":"2015-03-26 ","a":"35","b":"12"},{"y":"2015-03-26 ","a":"17","b":"2"}]

I was hoping there was some way of separating them like so:

[{"y":"2015-03-26","a":"16","b":"14"},{"y":"2015-03-26 ","a":"59","b":"12"},{"y":"2015-03-26 ","a":"21","b":"5"}],[{"y":"2015-03-26 ","a":"35","b":"12"},{"y":"2015-03-26 ","a":"17","b":"2"}]

So that it’s multiple arrays of data based on which ID it is. Hope that makes sense, thanks

One way of doing it would be to use an outer loop by ID and an inner loop to retrieve the values for each ID value, something like this:

<?php
// test data
$valueSDate = "2015-03-26";
$valueEDate = "2015-03-26";
$valueEA = "EA1";

$allData = array();
$con = odbc_connect(
        "Driver={Microsoft Access Driver (*.mdb, *.accdb)};" .
        "Dbq=C:\\Users\\Public\\Database1.accdb;",
        "Admin", "");
$rs1 = odbc_exec($con, 
        "SELECT DISTINCT ID " .
        "FROM MasterUsageTable " .
        "WHERE EA_Number = '$valueEA' " .
            "AND D BETWEEN #$valueSDate# AND #$valueEDate#");
while ($row1 = odbc_fetch_array($rs1)) {
    $id = $row1["ID"];
    $rs2 = odbc_exec($con, 
            "SELECT D as y,Total as a,PoweredOn as b " .
            "FROM MasterUsageTable " .
            "WHERE ID = $id AND EA_Number = '$valueEA' " .
                "AND D BETWEEN #$valueSDate# AND #$valueEDate#");
    $idData = array();
    while ($row2 = odbc_fetch_array($rs2)) {
        $idData[] = $row2;
    }
    $allData[] = $idData;
}

echo json_encode($allData);