Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/09/2010, 16:32
ommm
 
Fecha de Ingreso: septiembre-2010
Mensajes: 92
Antigüedad: 13 años, 7 meses
Puntos: 1
Pregunta Respuesta: Sumar registros de la misma tabla sql

Además de hacer el count segun la jefatura, intento hacer un DISTINC y no....


Código PHP:
$result=mysql_query("SELECT 
    jefatura, timbre
FROM
   ext
WHERE
   jefatura IN (
    SELECT DISTINCT jefatura
   FROM ext)"
,$link);

$suma=mysql_query("SELECT jefatura, COUNT(*) FROM ext WHERE jefatura='$row[1]' GROUP BY jefatura",$link);
$numero_filas=mysql_num_rows($suma);

echo
"<table width=600>
<tr>
<td><b>Jefatura</b></td><td><b>Extintores</b></td></tr>"
;
while(
$row=mysql_fetch_row($result)){
  echo
"<tr>
    <td>$row[1]</td><td>$numero_filas</td>
    </tr>"
;
}
echo
"</table>"

Como suma me da 0....


Gracias