[ Foro de SQL (y MySQL) ]

duda al mostrar suma de total en 0

14-Sep-2017 22:24
ixchel brust
0 Respuestas

hola
que tal  ,soy nueva en el foro y en esto de la programación  espero me puedan  echar la mano     de  un total de  datos  necesito mostrar  todos aquellos que la suma del  total real  sin iva   sea diferente  de 0  por cada articulo , mes  y año

este es el código que tengo
SELECT

[ROW_NUMBER],[Asiento],[Documento],[TIPO DE DOCUMENTO],[CODIGO RECETA],[ARTICULO RECETA]
,[CODIGO ARTICULO],[ARTICULO],[PROYECTO],[PARTIDA],[SUBPARTIDA],[CONCEPTO],[linenum]
,[ACCTCODE],[CANTIDAD],[total linea],[iva],[TOTAL DOC.],[CUENTA CONTABLE],[documento base]
,[total real],[descuento],[TOTAL ASIENTO],[TOTAL PRODUCCION],[ORDEN DE  FABRICACION],[TIPO]
,[STATUS],[REF. SISTEMAS],[desviacion],[f. entrega],[total entregado],[presupuesto],[OC/TOTAL]
,[Comentario],[GRUPO],[ACTIVO/INACTIVO],[EN/TOTAL],[AVANCE],[FECHA CONTABLE],[TOTAL TERMINADO]
,[SUPERFICIE],[Nombre Socio],[Total Real sin Iva]


 FROM [Ferterra].[dbo].[INMUEBLES] as b

 group  by

[ROW_NUMBER],[Asiento],[Documento],[TIPO DE DOCUMENTO],[CODIGO RECETA],[ARTICULO RECETA]
,[CODIGO ARTICULO],[ARTICULO],[PROYECTO],[PARTIDA],[SUBPARTIDA],[CONCEPTO],[linenum]
,[ACCTCODE],[CANTIDAD],[total linea],[iva],[TOTAL DOC.],[CUENTA CONTABLE],[documento base]
,[total real],[descuento],[TOTAL ASIENTO],[TOTAL PRODUCCION],[ORDEN DE  FABRICACION],[TIPO]
,[STATUS],[REF. SISTEMAS],[desviacion],[f. entrega],[total entregado],[presupuesto],[OC/TOTAL]
,[Comentario],[GRUPO],[ACTIVO/INACTIVO],[EN/TOTAL],[AVANCE],[FECHA CONTABLE],[TOTAL TERMINADO]
,[SUPERFICIE],[Nombre Socio],[Total Real sin Iva]

having
(SELECT  
  [toTAL REAL]
 FROM [Ferterra].[dbo].[inmuebles sumatorias] as a
 where  [AÑO]=year(b.[FECHA CONTABLE])  and [MES]= month(b.[FECHA CONTABLE]) and b.[CODIGO ARTICULO]= [CODIGO ARTICULO])<>0

pero no me da el resultado esperado  es decir  
si el articulo en el mes  1 y  año  1   donde el  total  es  diferente  que   0  se  debe mostrar
y si ese mismo articulo en el mes 2  año 1  es  igual a  0  no se  debe mostrar

ojala me puedan orientar  

muchas  gracias  y saludos




(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)