/*----------------------------------------
Use to determine the number of pints sold
by keg by store for a period of time.
Change the Aloha Store ID, InStore ID,
Ingredent, Start and End Times
------------------------------------------
*/
Use RUDY
Declare @Ingred Char(19)
Declare @InStoreID Char(5)
Declare @AlohaID Char(10)
Declare @StartDate DateTime
Declare @EndDate DateTime
set @InStoreID = '00200' --Instore ID
set @AlohaID ='6483' --Aloah ID
set @Ingred = 'kb dos xx' --InStore Item Code
Set @StartDate = '08/25/2006 12:45 PM' --Start date time
Set @EndDate = '08/27/2006 11:17 PM' --End date time
select PLUNumber, IngredQty
Into #temp_Beer
from arm01011
Where Ingredient = @Ingred
and StoreID = @InStoreID
Use ALOHA_POS
select *,
DateofBusiness1 = cast(convert (char(11), DateOfBusiness, 101) + ' ' + cast([Hour] as char(2)) + ':' + cast([Minute] as char(2)) as datetime)
into #temp1
from repman.dpvHstGndItem
where FKStoreId = @AlohaID and
FKItemId in (Select PLUNumber From #temp_Beer)
select FKItemId, Count(FKItemId) as UnitsSold
Into #temp_UnitsSold
from #temp1
where DateofBusiness1 @StartDate and @EndDate
Group by FKItemId
Select Sum(b.IngredQty * u.UnitsSold)/15 as PintsSold
From #temp_Beer b inner join #temp_UnitsSold u
on b.PLUNumber = u.FKItemId
Drop Table #temp_Beer
Drop table #temp_UnitsSold
drop table #temp1
|