Hi basically my aim is to get total weight count and its sum form specific range , like :
0.1 to 0.5 or 0.6 - 1.0 or 1.01 - 1.50 .... so on on...
Hence for each range i have to write separate select query ? like below :
SELECT count(*),sum(wght) FROM PROD WHERE wght BETWEEN 0.1 AND 0.5
SELECT count(*),sum(wght) FROM PROD WHERE wght BETWEEN 0.6 AND 1.0
SELECT count(*),sum(wght) FROM PROD WHERE wght BETWEEN 1.01 AND 1.5
It may have many range like above its not fixed.
Hence result i want is as below :
0.1 - 0.5 = 3 / 9.4 - ( its total count / sum of weight )
0.6 - 1.0 = 2 / 4.5
1.01 - 1.5 = 0 / 0
... so on and on....
Hence i taught to keep that range in an multidimensional array and pass to select query in for loop / for each as below :
$info = array("0" =>array("a1"=>0.1,"a2"=>0.5),
"1" => array("b1"=>0.6,"b2"=>1.0),
"2" => array("c1"=>1.01,"c2"=>1.5),
"3" => array("d1"=>1.51,"d2"=>2.0)
);
echo"<table>";
foreach($info as $row) {
echo('<tr>');
foreach($row as $cell) {
echo('<td>' . $cell . '</td>');
$sql = "SELECT count(*),sum(wght) FROM PROD WHERE wght BETWEEN ".$cell." and ??????";
}
echo('</tr>');
}
echo "</table>";
AS ITS taking each single value in SELECT value , when i echo sql select i see 8 times select query , where as i should get only 4 select query as per ranges
how i can work out with BETWEEN
IF ANY OTHER SUGGESTION TO GET BELOW RESULT PLEASE LET ME KNOW :
0.1 - 0.5 = 3 / 9.4 - ( its total count / sum of weight )
0.6 - 1.0 = 2 / 4.5
1.01 - 1.5 = 0 / 0
... so on and on....