Christar
asked on
Product Sales by Customer over date peroid
Hi Experts,
I am looking for an Access query that will give me sales data for a particular product to a particular customer over a particular time period.
The tables and relevant fields are:
1)dbo.tblWEEKLYSALES
fld.ProductID
fld.Qty
fld.CustomerNum
fld.BusinessDate
2)dbo.tblCUSTOMER
fld.CustomerNum
3)dbo.tblPRODUCT
fldProductID
fldDescription
So far I have:
SELECT dbo_tblCUSTOMER.fld.Custom erNum, dbo_tblWEEKLYSALES.fldProd uctID, dbo_tblPRODUCT.fldDescript ion, dbo_tblWEEKLYSALES.fldQty, dbo_tblWEEKLYSALES.fldBusi nessDate
FROM (dbo_tblWEEKLYSALES LEFT JOIN dbo_tblPRODUCT ON dbo_tblWEEKLYSALES.fldProd uctID = dbo.tblPRODUCT.fldProductI D) LEFT JOIN dbo.tblCUSTOMER ON dbo_tblWEEKLYSALES.fldCust omerNum= dbo.tblCUSTOMER.fldCustome rNum
WHERE (((dbo.tblCUSTOMER)="74831 ") AND ((dbo_tblWSALES.fldProduct ID)=" 4957"));
This is fine but I want to be able to return the sales over say the last 2 months. How might I do this with fldBusinessDate? I am sure this is relatively straightforward but I have done some searching and am out of time...
Thanks!
Chris
I am looking for an Access query that will give me sales data for a particular product to a particular customer over a particular time period.
The tables and relevant fields are:
1)dbo.tblWEEKLYSALES
fld.ProductID
fld.Qty
fld.CustomerNum
fld.BusinessDate
2)dbo.tblCUSTOMER
fld.CustomerNum
3)dbo.tblPRODUCT
fldProductID
fldDescription
So far I have:
SELECT dbo_tblCUSTOMER.fld.Custom
FROM (dbo_tblWEEKLYSALES LEFT JOIN dbo_tblPRODUCT ON dbo_tblWEEKLYSALES.fldProd
WHERE (((dbo.tblCUSTOMER)="74831
This is fine but I want to be able to return the sales over say the last 2 months. How might I do this with fldBusinessDate? I am sure this is relatively straightforward but I have done some searching and am out of time...
Thanks!
Chris
or
WHERE (((dbo.tblCUSTOMER)="74831 ") AND ((dbo_tblWSALES.fldProduct ID)=" 4957") And dbo_tblWEEKLYSALES.fldBusi nessDate Between Date() And DateSerial(Year(Date), (Month(Date) - 2), 1))
WHERE (((dbo.tblCUSTOMER)="74831
ASKER
hmmmm.. this dosen't seem to be generating correct data. The results are blank but i know there have been sales over the last couple of months. Ill keep playing with it. Thanks
ASKER
Thanks Capricorn1,
When i the second suggestion it asks me to 'Enter Parameter Value" Date. Is there somewhere i should be using fldBusinessDate rather than just Date?
Cheers,
Chris
When i the second suggestion it asks me to 'Enter Parameter Value" Date. Is there somewhere i should be using fldBusinessDate rather than just Date?
Cheers,
Chris
try
WHERE (((dbo.tblCUSTOMER)="74831 ") AND ((dbo_tblWSALES.fldProduct ID)=" 4957") And dbo_tblWEEKLYSALES.fldBusi nessDate Between Date() And DateSerial(Year(Date()), (Month(Date()) - 2), 1))
WHERE (((dbo.tblCUSTOMER)="74831
ASKER
Again this query seems to execute fine but is not giving me any data when i know it exists.
Did I mention my date format is DD/MM/YYYY. Might this be relevant?
Did I mention my date format is DD/MM/YYYY. Might this be relevant?
ASKER
sorry that was an error the date format is: MM/DD/YYYY
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cool thats seemed to do it! Thanks Capricorn! Out of curiosity why the need to format? Do I have my data in an awkward date format?
many thanks again for the assistance.
Cheers,
Chris
many thanks again for the assistance.
Cheers,
Chris
perhaps, time ? sometime you have to use brute force to equate the date/time field of access
ASKER
hahaha no wonder i couldn't figure it out. I am a bit weak in the Access world! Thanks!
try this
WHERE (((dbo.tblCUSTOMER)="74831