duda: ¿que es "temp"?
buen dia,
tengo esta consulta:
select
temp.*, itd.folio
from inv_transacciones_detalle itd
inner join
(select
ce.establecimiento
, ce.descripcion nombre_establecimiento
, ca.clave_almacen almacen
, ca.nombre nombre_almacen
, ci.sku
, ci.codigo_sis
, ci.descripcion
, ism.fecha_registro
, ismd.costo_unitario
, sum(ismd.cantidad) cantidad
from
inv_salidas_merma ism
inner join
inv_salidas_merma_detalle ismd
on ism.numero_transaccion = ismd.numero_transaccion
inner join cat_establecimientos ce
on ism.establecimiento = ce.establecimiento
inner join cat_almacenes ca
on ism.establecimiento = ca.establecimiento
and ism.almacen = ca.clave_almacen
inner join
cat_insumos ci
on ismd.sku = ci.sku
where ism.fecha_registro >= '2014-05-17'/*pfechainicial*/
and ism.fecha_registro <= '2014-05-19'/*pfechafinal*/
and ism.establecimiento = case 0/*pestablecimiento*/ when 0 then ism.establecimiento else 0/*pestablecimiento*/ end
and ism.almacen = case 0/*palmacen*/ when 0 then ism.almacen else 0/*palmacen*/ end
and ci.categoria = case 1 /*pcategoria*/ when 0 then ci.categoria else 1/*pcategoria*/ end
and ci.subcategoria = case 1/*psubcategoria*/ when 0 then ci.subcategoria else 1/*psubcategoria*/ end
and ci.tipo_producto = case 0/*ptipoproducto*/ when 0 then ci.tipo_producto else 0/*ptipoproducto*/ end
and ci.marca = case 0/*pmarca*/ when 0 then ci.marca else 0/*pmarca*/ end
group by
ce.establecimiento
, ca.clave_almacen
, ci.sku
, ism.fecha_registro
order by
ce.establecimiento
, ca.clave_almacen
, ci.sku) temp
on itd.establecimiento = temp.establecimiento
and itd.almacen = temp.almacen
and itd.sku = temp.sku
where
itd.fecha >= ('2014/05/17')
and itd.fecha <= ('2014/05/19')
and itd.establecimiento = case 0/*pestablecimiento*/ when 0 then itd.establecimiento else 0/*pestablecimiento*/ end
and itd.almacen = case 0/*palmacen*/ when 0 then itd.almacen else 0/*palmacen*/ end
and coalesce(itd.cantidad, 0) <> 0
;
Subject
Views
Written By
Posted
duda: ¿que es "temp"?
1780
May 28, 2014 02:49PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.