Error in MySQL query

0

Someone can help me, how can I not join the fields of a query, that is, I ask the question and if it is the same product instead of showing me the 2 rows shows me 1 but adding the 2, the I show you to understand.

And this is the sentence I am using:

SELECT IL.Cliente, CA.Programa, IL.Estilo, IL.Color, SUM(IL.Total) AS Pares, CA.Material, CA.Departamento, CA.Fecha_Pago AS Fecha_Pedido 
FROM galaxyfx_produccion.compras_ange AS CA 
INNER JOIN galaxyfx_produccion.infolote AS IL ON CA.Programa = IL.Programa 
WHERE (CA.Programa LIKE '%40680%') AND (CA.Estado = 'En Espera') 
GROUP BY CA.Programa, CA.Material, CA.Departamento;

I already try everything but it's not there.

    
asked by Macx 28.09.2018 в 19:14
source

1 answer

1

As I understand, what you need is that you do not add the value of your Total column, you are adding the value because in the query you have the SUM() instruction. To prevent me from doing the sum, remove the instruction. Your query should look something like this:

SELECT IL.Cliente, CA.Programa, IL.Estilo, IL.Color, **IL.Total** AS 
Pares, CA.Material, CA.Departamento, CA.Fecha_Pago AS Fecha_Pedido 
FROM galaxyfx_produccion.compras_ange AS CA 
INNER JOIN galaxyfx_produccion.infolote AS IL ON CA.Programa = IL.Programa 
WHERE (CA.Programa LIKE '%40680%') AND (CA.Estado = 'En Espera') 
GROUP BY CA.Programa, CA.Material, CA.Departamento;

Maybe you have to add IL.Total to Group By since I do not know the structure of your database I can not tell you with certainty.

    
answered by 28.09.2018 в 21:40