Subversion Repositories SmartDukaan

Rev

Rev 10407 | Rev 10689 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10407 Rev 10489
Line 370... Line 370...
370
	ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity 
370
	ci.color as color, (x.inx-if(y.outx is null,0,y.outx)) as quantity 
371
	FROM 
371
	FROM 
372
		(SELECT i.itemId, count(*) as inx FROM scanNew s JOIN inventoryItem i ON 
372
		(SELECT i.itemId, count(*) as inx FROM scanNew s JOIN inventoryItem i ON 
373
		(i.id = s.inventoryItemId) JOIN catalog.item c ON i.itemId = c.id 
373
		(i.id = s.inventoryItemId) JOIN catalog.item c ON i.itemId = c.id 
374
		where s.type in ('DOA_IN', 'SALE_RET_UNUSABLE') and 
374
		where s.type in ('DOA_IN', 'SALE_RET_UNUSABLE') and 
375
		s.scannedAt < #{date} group by i.itemId ) as x 
375
		s.scannedAt < #{date} and s.scannedAt > '2013-01-01' group by i.itemId ) as x 
376
		LEFT JOIN 
376
		LEFT JOIN 
377
		(SELECT i.itemId, count(*) as outx FROM scanNew s JOIN inventoryItem i ON
377
		(SELECT i.itemId, count(*) as outx FROM scanNew s JOIN inventoryItem i ON
378
		i.id = s.inventoryItemId JOIN catalog.item c ON i.itemId = c.id WHERE 
378
		i.id = s.inventoryItemId JOIN catalog.item c ON i.itemId = c.id WHERE 
379
		s.type in ('DOA_OUT') and s.scannedAt < #{date} group by i.itemId) as y 
379
		s.type in ('DOA_OUT') and s.scannedAt < #{date} and s.scannedAt > '2013-01-01' 
-
 
380
		group by i.itemId) as y 
380
		ON x.itemId = y.itemId 
381
		ON x.itemId = y.itemId 
381
		JOIN catalog.item ci ON ci.id = x.itemId 
382
		JOIN catalog.item ci ON ci.id = x.itemId 
382
	having quantity>0;
383
	having quantity>0;
383
</select>
384
</select>
384
 
385