Foro de elhacker.net

Programación => Desarrollo Web => Mensaje iniciado por: joalbela en 26 Febrero 2012, 06:19 am



Título: Inconveniente con agrupacion de datos
Publicado por: joalbela en 26 Febrero 2012, 06:19 am
Buenas noches

Me gustaria que me ayudaran con el inconveniente que estoy presentando, tengo la siguiente consulta pero me esta trayendo los registros repetidos, necesito que solo me traiga un registro de cada noimbre de compañia


SELECT DISTINCT  C.NOMBRES,
CASE Month(v.fecha) when  '1' THEN ROUND(SUM(v.valor_total),0) end enero,
CASE Month(v.fecha) when  '2' THEN ROUND(SUM(v.valor_total),0) end Febrero,
CASE Month(v.fecha) when  '3' THEN ROUND(SUM(v.valor_total),0) end Marzo,
CASE Month(v.fecha) when  '4' THEN ROUND(SUM(v.valor_total),0) end Abril,
CASE Month(v.fecha) when  '5' THEN ROUND(SUM(v.valor_total),0) end Mayo,
CASE Month(v.fecha) when  '6' THEN ROUND(SUM(v.valor_total),0) end Jumio
FROM CLIENTES C  JOIN VENTAS V on C.NIT=V.NIT
WHERE   Month(v.fecha)  between '2'and '6'
GROUP BY C.NOMBRES, Month(v.fecha)
ORDER BY C.NOMBRES

Muchas gracias