Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/09/2008, 06:28
Avatar de Yedi
Yedi
 
Fecha de Ingreso: junio-2006
Ubicación: México
Mensajes: 159
Antigüedad: 17 años, 10 meses
Puntos: 2
Respuesta: Sumar un resultado que sale de una suma

Hola de hecho hize mi siguiente consulta pero no me funciono
SELECT productos.nombre_generico, (SUM(detallesregistro.cantidad)) as cantidad, (SUM(detallesregistro.cantidad) * detallesregistro.preciototal) as (SUM(preciofinal)) as total , detallesregistro.preciototal
FROM productos
INNER JOIN detallesregistro ON productos.cveproducto = detallesregistro.cveproducto
INNER JOIN registro ON detallesregistro.cveregistro = registro.cveregistro
WHERE cvepaciente = '15' and detallesregistro.cveregistro = '1' group by nombre_generico

Y me sale el siguiente error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '( SUM( preciofinal ) ) as total , detallesregistro.preciototal FROM productos ' at line 1
entonces no se como estructurar mi consulta
Gracias por tus comentarios