Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/04/2011, 06:10
betodaniel61
Usuario no validado
 
Fecha de Ingreso: abril-2009
Ubicación: Buenos Aires
Mensajes: 413
Antigüedad: 15 años
Puntos: 3
Respuesta: Funcion de saldo en MySql

Buen Dia Quimfv:
Estoy haciendo una prueba en el SQL de PhpMyadmin con el codigo:
SELECT sum(if(signo='+',importe,0)) as ingresos,
sum(if(signo='-',importe,0)) as reintegros
sum(if(signo='+',importe,0)-if(signo='-',importe,0)) as Saldo
FROM cuentacorriente LEFT JOIN tipomovimientos USING (idtipomovimiento)
WHERE idusuario=2
y me da 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(if(signo='+',importe,0)-if(signo='-',importe,0)) as Saldo FROM cuentacorrie' at line 3

La verdad no se que problema estoy teniendo.
Muchas Gracias por tu ayuda