I need to query an SQL
database
to get all purchased products on last working date. For example, on Monday
I
need to get the records of Saturday
.
Also suppose due to some reason Tuesday
is
my leave I need to get the records of Monday
.
I tried my query like:
select ProductName , count(ProductName) as [No Of Products],SUM(Total) as [TotalCost]
from dbo.TransactionDetails
where CurrentTime >=dateadd(day,datediff(day,1,GETDATE()),0)
AND CurrentTime <dateadd(day,datediff(day,0,GETDATE()),0)
and Transaction='BUY'
group by ProductName
But here I am only getting the details of last date.
Also I tried by checking on my last closed shifts:
select ProductName , count(ProductName) as [No Of Products],SUM(Total) as [TotalCost] from dbo.TransactionDetails where CurrentTime = (select MAX(Cast(CurrentDateTime as DATE))
from CloseShifts) and Transaction='BUY' group by ProductName
But still I am not getting any result.
M.Sabyasachi