this is my query:
SELECT clientes.nombre as [NombreCliente],
venta.usuario as [NombreVendedor],
SUM((listaventa.precio) ) as [FinalTotal],
venta.id as [IdVenta],
venta.fecha as [Fecha],
idproducto as [clave],
producto.descripcion ,
listaventa.precio as [preciounitario],
listaventa.cantidad,
listaventa.total as [PrecioTtoal]
FROM venta
JOIN clientes on venta.idcliente = clientes.id
JOIN listaventa on listaventa.idventa=venta.id
JOIN producto on listaventa .idproducto =producto.id
WHERE venta.id ='36'
GROUP BY clientes.nombre, venta.usuario, venta.id, venta.fecha, listaventa.idproducto, producto.descripcion, listaventa.precio, listaventa.cantidad, listaventa.total
Problem is, I don't get is sum, as query is checking id for id, it never return a sum(listaventa.precio) it returns the same than cantidad*preciou (of every product but it never sum it). Else if i try it
SELECT clientes.nombre as [NombreCliente],
venta.usuario as [NombreVendedor],
SUM((listaventa.precio) ) as [FinalTotal],
venta.id as [IdVenta],
venta.fecha as [Fecha],
idproducto as [clave],
producto.descripcion ,
listaventa.precio as [preciounitario],
listaventa.cantidad,
listaventa.total as [PrecioTtoal]
FROM venta
JOIN clientes on venta.idcliente = clientes.id
JOIN listaventa on listaventa.idventa=venta.id
JOIN producto on listaventa .idproducto =producto.id
WHERE venta.id ='36'
AND venta.id IN (SELECT *
FROM listaventa
WHERE idventa = 36)
I get this error:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.