I have 2 tables:
Table1 is filled daily with information about clients from a legacy system.
Every day we determine which client is "new" in that table with a query that is comparing today's records with yesterday's records. The outcome is used in a form showing "new" records in the table. This...
Found it [bigsmile] (thanks to http://dba.stackexchange.com/)
This query produces the results I need
SELECT
s.Saledate,
s.SaleQ,
s.ProdID,
p.Price,
p.PriceDate
FROM
tblSales AS s
LEFT JOIN
tblPrices AS p
ON
p.ProdID = s.ProdID
AND
p.Datum...
I think you are on the right track. Only q is not defined. Running the query it ask for q.price and q.pricedate to enter a value. I suspect that q.price and q.pricedate should be p.price and p.pricedate but then I get the message "the specified field p.price could refer to more then one table in...
Sorry I did not want to confuse you. And I did not know about PRE tag either,
I will try again
tblSales
tblSales.SaleDate tblSales.ProdID tblSales.SaleQ
04-02-2015 1 530
05-02-2015 1 370
06-02-2015 1...
Again fast response.
I Appreciate your help, but this time I still don't get the expected result.
The query shows all sales after the last date the price has changed, but these sales are compared with all price records I have.
I have a price table with 3 prices
02-01-2015 25
02-10-2015 23...
SELECT tblSales.SaleQ, tblPrices.Price, tblPrices.PriceDate, tblSales.SaleDate
FROM tblSales LEFT JOIN tblPrices ON tblSales.ProdID = tblPrices.ProdID
WHERE (
SELECT
MAX(tblPrices.PriceDate)
FROM tblPrices
WHERE
tblOpgewekteEnergie.Prod = tblEnergiePrijzen.Prod
) <=...
Whow that was a quick response [bigsmile]
Unfortunately this suggestion does not change the outcome. The result of my query is that I get all records from tblPrices and all records from tblSales. I still have no clue
@SkipVought
I have tried your suggestion, but yet succeeded.
SELECT tblSales.SaleQ, tblPrices.Price, tblPrices.PriceDate, tblSales.SaleDate
FROM tblSales LEFT JOIN tblPrices ON tblSales.ProdID = tblPrices.ProdID
WHERE (
SELECT MAX(tblPrices.PriceDate)
FROM tblPrices
) <= tblSales.SaleDate
GROUP...
SkipVought I am afraid I don't understand your comment. At the moment I have no interest in inventory, just combine sales with prices. And my example does give data.
Please explain what you mean.
Hi, I am trying to figure out how to match a sale date to a price date.
I have three tables:
tblProd
ID
Desc
tblPrices
PriceDate
Price
ProdID
tblSales
SaleDate
SaleQ
ProdID
Prices do not change frequently, so the tblPrice is not updated regularly.
What I would like to achieve is to find a...
Hi, I am trying to figure out how to match a sale date to a price date.
I have three tables:
tblProd
ID
Desc
tblPrices
PriceDate
Price
ProdID
tblSales
SaleDate
SaleQ
ProdID
Prices do not change frequently, so the tblPrice is not updated regularly.
What I would like to...
Hi Mazework.
I am familiar with the BETWEEN statement.
The reason for trying to create a function is that my "calculations" are more complicated then just BETWEEN. I will provide some examples.
Item 1 with starting date of 2-1-2010 and end date of 1-31-2011
Item 2 with starting date of 7-1-2010...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.