Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/08/2009, 07:58
Avatar de JuJoGuAl
JuJoGuAl
 
Fecha de Ingreso: julio-2009
Ubicación: Venezuela
Mensajes: 754
Antigüedad: 14 años, 9 meses
Puntos: 19
Consulta agrupando por varias condiciones

No se si me explique con claridad veran tengo esta tabla "difuntos_totales" la cual posee estos campos:
Código PHP:
`Difunto_IDint(10unsigned NOT NULL default '0',
  `
FMuertedate default NULL,
  `
FEnterramientodate default NULL,
  `
Nombre_Apellidovarchar(100) default NULL,
  `
Edadvarchar(15) default NULL,
  `
Inhumacionint(10unsigned default NULL,
  `
Defuncion_Localint(10unsigned default NULL,
  `
Parroquiavarchar(15) default NULL,
  `
Cod_Bovedaint(10unsigned default NULL,
  `
Tipo_Bovedavarchar(10) default NULL,
  `
Bloqueint(2unsigned default NULL,
  `
Gratisint(2unsigned default '0'
y tiene estos Registros basicamente:

Código PHP:
DIA-Tipo_Boveda
12
-Sencilla
12
-Sencilla
12
-Sencilla
12
-Sencilla
12
-Sencilla
12
-Sencilla
12
-Sencilla
12
-Doble
12
-Restos
12
-Infantil
12
-Sencilla
13
-Sencilla 
y mi codigo es:
Código PHP:
<table border="1" width="100%">
       <tr>
             <td rowspan="2" align="center" class="Reporte" width="5%"><font size="2"><b>Fecha</b></td>
             <td colspan="3" align="center" class="Reporte" width="5%"><font size="2"><b>Sencillas</b></td>
             <td colspan="3" align="center" class="Reporte" width="5%"><font size="2"><b>Dobles</b></td>
             <td colspan="3" align="center" class="Reporte" width="5%"><font size="2"><b>Infantiles</b></td>
             <td colspan="3" align="center" class="Reporte" width="5%"><font size="2"><b>Restos</b></td>
             <td colspan="3" align="center" class="Reporte" width="5%"><font size="2"><b>Fetos</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Ingreso</b></td>
         </tr>
         <tr>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Cantidad</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Costo</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Total</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Cantidad</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Costo</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Total</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Cantidad</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Costo</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Total</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Cantidad</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Costo</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Total</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Cantidad</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Costo</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Total</b></td>
             <td align="center" class="Reporte" width="5%"><font size="2"><b>Total:</b></td>
         </tr>
<?php
include("config.php");
$Boveda mysql_query("SELECT day(FMuerte) as dia, tipo_boveda FROM difuntos_totales");
$fecha;
$Sencilla=0;
$Doble=0;
$Infantil=0;
$Restos=0;
$Feto=0;
while (
$row=mysql_fetch_assoc($Boveda))
{
if (
$row["dia"]>0)
{
$fecha=$row["dia"];
}
if (
$row["tipo_boveda"]=="Sencilla")
{
$Sencilla=$Sencilla+1;
}
if (
$row["tipo_boveda"]=="Doble")
{
$Doble=$Doble+1;
}
if (
$row["tipo_boveda"]=="Infantil")
{
$Infantil=$Infantil+1;
}
if (
$row["tipo_boveda"]=="Restos")
{
$Restos=$Restos+1;
}
if (
$row["tipo_boveda"]=="Feto")
{
$Feto=$Feto+1;
}
    echo 
"<tr>
    <td class=\"Reporte\" align=center>$fecha</span></td>
    <td class=\"Reporte\" align=center>$Sencilla</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>$Doble</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>$Infantil</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>$Restos</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>$Feto</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>
    <td class=\"Reporte\" align=center>&nbsp;</span></td>"
    
;
        
$Sencilla=0;
    
$Doble=0;
    
$Infantil=0;
    
$Restos=0;
    
$Feto=0;
    
$fecha=0;
}
mysql_free_result($Boveda)
?>
</table>
y necesito que me arroje algo como:
Dia=12 SENCILLAS=8 / Dobles=1 / Restos=1 / Intanfil=1
Dia13 Sencillas=1


Todo eso en una tabla porque es un informe.... :S

Como Puedo hacer????