on 02-04-2016 9:45 PM
Buen día expertos
una vez mas solicitando de su apoyo con una consulta donde arroje la venta de artículos total por mes respetando moneda y tome en cuenta las notas de crédito y pregunte de que marca fecha se desea consultar
MARCA
CODIGO DESCRIP. CANTIDAD $-USD PRECIO DOCUMENTO CLIENTE $-USD TOTAL
por su atención y apoyo gracias!!
Hola Cesar,
Deseas que el total de los documentos se presenten en ambas monedas, o que aparezca en una u otra segun haya sido creado? y explicame lo de "marca fecha"
Saludos.
Carlos.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Que tal Carlos Bonilla, gracias por atender
si, lo de marca fechas es. al ejecutar la consulta te pregunte el grupo o familia de los item y la fecha el periodo en el que deseas consultar las ventas del mismo
algo asi:
GRUPO / FAMILIA | SIEMENS |
FECHA SUPERIOR O IGUAL | 0101/2016 |
FECHA MENOR O IGUAL | 31/01/2016 |
Cesar, mira hay una diferencia entre la Marca (FAbricante) y el grupo de articulos. Entendiendo que te refieres a la marca y no al grupo de articulos (es donde se definen las cuentas contrapartida), prueba este query:
select t2.itemcode,t3.itemname,sum(t2.quantity) Cantidad,t2.price [Precio], t2.Currency, t4.FirmName, sum(linetotal) Total
from oinv t1, inv1 t2, oitm t3, OMRC t4 where t1.docentry=t2.docentry and t2.itemcode=t3.itemcode and t3.FirmCode=t4.FirmCode and (t1.docdate)>='[%0]' and t1.docdate<='[%1]' and t4.firmname='[%2]'
group by t2.itemcode,t3.itemname,t2.price,t2.Currency, t4.firmname
Espero te sirva.
Saludos.
Carlos Bonilla.
Carlos Bonilla esta muy bien el query como lo muestras muchas gracais, cambie la tabla de OMRC por OITB, grupo de artículos ya que es la forma en la que se necesita ver las ventas de esos item, pero no me muestra nada parece que algo no hice bien
por otro lado me gustaría saber si esta tomando en cuenta las notas de crédito que se hayan hecho de esas ventas
gracias por tu atención y apoyo
select t2.itemcode,t3.itemname,sum(t2.quantity) Cantidad,t2.price [Precio], t2.Currency, t4.ItmsGrpNam, sum(linetotal) Total
from oinv t1, inv1 t2, oitm t3, oitb t4 where t1.docentry=t2.docentry and t2.itemcode=t3.itemcode and t3.FirmCode=t4.ItmsGrpCod and (t1.docdate)>='[%0]' and t1.docdate<='[%1]' and t4.ItmsGrpNam='[%2]'
group by t2.itemcode,t3.itemname,t2.price,t2.Currency, t4.ItmsGrpNam
Tienes mal formulada la consulta.
select t2.itemcode,t3.itemname,sum(t2.quantity) Cantidad,t2.price [Precio], t2.Currency, t4.ItmsGrpNam, sum(linetotal) Total
from oinv t1 inner join inv1 t2 on t1.docentry=t2.docentry inner join oitm t3 on t2.itemcode=t3.itemcode inner join oitb t4 on t3.itmsgrpcod=t4.itmsgrpcod where (t1.docdate)>='[%0]' and t1.docdate<='[%1]' and t4.ItmsGrpNam='[%2]'
group by t2.itemcode,t3.itemname,t2.price,t2.Currency, t4.ItmsGrpNam
De todas formas la agrupación o la vista final de la información no sé si es lo que quieres o no.
Gracias por la corrección. la consulta es perfecta solo falta tome en cuenta las notas
de crédito y nos arroje las ventas reales de nuevo muchas garcias
Eso es muy sencillo.
Agregas un UNION ALL y cambias las tablas origen de los datos.
Para que sea coherente la información la cantidad y el total los haces negativos y ya la tienes.
select t2.itemcode,t3.itemname,sum(t2.quantity) Cantidad,t2.price [Precio], t2.Currency, t4.ItmsGrpNam, sum(linetotal) Total
from oinv t1 inner join inv1 t2 on t1.docentry=t2.docentry inner join oitm t3 on t2.itemcode=t3.itemcode inner join oitb t4 on t3.itmsgrpcod=t4.itmsgrpcod where (t1.docdate)>='[%0]' and t1.docdate<='[%1]' and t4.ItmsGrpNam='[%2]'
group by t2.itemcode,t3.itemname,t2.price,t2.Currency, t4.ItmsGrpNam
UNION ALL
select t2.itemcode,t3.itemname,sum(t2.quantity)*-1 Cantidad,t2.price [Precio], t2.Currency, t4.ItmsGrpNam, sum(linetotal)*-1 Total
from orin t1 inner join rin1 t2 on t1.docentry=t2.docentry inner join oitm t3 on t2.itemcode=t3.itemcode inner join oitb t4 on t3.itmsgrpcod=t4.itmsgrpcod where (t1.docdate)>='[%0]' and t1.docdate<='[%1]' and t4.ItmsGrpNam='[%2]'
group by t2.itemcode,t3.itemname,t2.price,t2.Currency, t4.ItmsGrpNam
User | Count |
---|---|
91 | |
10 | |
10 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.