YOU ARE THE MAN. There must be a way I can pay you back or return the
favor?
I went to the site on your footer; do you do consulting work?
Have an awesome day!
Jerold
:
Hi, Jerold.
And the response was: "ENTER PARAMETER VALUE" (Loan.TransactionDate)
This means that the Loan table doesn't have a column named
TransactionDate.
Check the spelling to ensure that your query matches the name of the
column
in the table.
FROM Loan AS Loan
The name of the table doesn't need to be aliased (that's what the "AS"
keyword is telling the database engine: to use the aliased name
"Loan"
in
place of the actual name "Loan") if it's the same as the original
name.
You
can change that line of SQL to:
FROM Loan
I entered the above language into a "blank" query (sql) sheet. Is
this
fine
Yes.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and
tutorials.
Blog:
http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for
contact
info.
One day I am going to get this right. Also, I changed some of the
names
to
be
more simplistic. This is what I wrote
SELECT Loan.SSN, Loan.TransactionDate, Loan.DueDate,
DATEDIFF("D",
(SELECT MAX(L.DueDate)
FROM Loan AS L
WHERE (L.SSN = Loan.SSN) AND (L.DueDate < Loan.TransactionDate)),
Loan.TransactionDate) AS DaysBetwLoans
FROM Loan AS Loan
GROUP BY Loan.SSN, Loan.TransactionDate, Loan.DueDate
And the response was: "ENTER PARAMETER VALUE" (Loan.TransactionDate)
I entered the above language into a "blank" query (sql) sheet. Is
this
fine
or should I have added the "Loan table" with it?
:
Hi, Jerold.
Not sure if this makes sense.
It makes sense, but it's full of errors. Remove the brackets and
try
to
run
the query and you'll see what I mean. Only alphanumeric characters
and
the
underscore are allowed in names. One should never have to add
brackets
to
names to get the query to run.
What I gave you in my example was a formula for the SQL statement
that
you
need to write for your query. Since you didn't give the names of
your
columns, I provided column names for due date, loan date, and the
customer
identification in my example. You aren't using those exact names,
but
if
I
had to guess, Loan is the name of your table, the SSN is the
customer
identification, and date of transaction is the loan date. You'll
have
to
figure out what the DueDate column in my example is equivalent to
in
your
table. I can help you part way by plugging in names into the
formula,
but
you need to fix the errors in your names.
If my guesses on your names are correct, your query should use this
formula:
SELECT M.SSN, M.TransactionDate, M.DueDate,
DATEDIFF("D",
(SELECT MAX(L.DueDate)
FROM Loan AS L
WHERE (L.SSN = M.SSN) AND (L.DueDate < M.TransactionDate)),
M.TransactionDate) AS DaysBetwLoans
FROM Loan AS M
GROUP BY M.SSN, M.TransactionDate, M.DueDate
Again, you'll have to figure out what's equivalent to DueDate and
replace
it
in the query above with your column's name.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and
tutorials.
Blog:
http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for
contact
info.
I forgot this part. This is what one of my queries:
SELECT Loan.[Amount of Personal Check], [Loan]![Amount of
Personal
Check]*0.15 AS Fee, [Loan]![Amount of Personal Check]*0.85 AS
[Customer's
Amount], [Loan]![Check Post Date]-[Loan]![Date of Transaction] AS
[Loan
Duration], ([Fee]/[Customer's Amount]/[Loan Duration])*365 AS APR
FROM Loan INNER JOIN [Customer Data] ON Loan.[Social Security #]
=
[Customer
Data].[Social Security #];
Not sure if this makes sense. I copied this from SQL view in
Access.
Jerold
:
Hi, Jerold.
How do I calculate the days between
previous due date and the new loan date, which is 6?
Use a subquery to compare with each record's loan date. For
example:
SELECT M.UserID, M.LoanDate, M.DueDate,
DATEDIFF("D",
(SELECT MAX(L.DueDate)
FROM tblLoans AS L
WHERE (L.UserID = M.UserID) AND (L.DueDate < M.LoanDate)),
M.LoanDate)
AS DaysBetwLoans
FROM tblLoans AS M
GROUP BY M.UserID, M.LoanDate, M.DueDate
.. . . where UserID is each customer's identification, LoanDate
is
the
date
of the loan, and DueDate is the date the loan is due. The alias
"M"
is
used
for the main query, which is the "current" loan, and the alias
"L"
is
used
for the subquery, which is the previous loan (maximum due date
previous
to
current loan date). Of course, this query assumes that each
customer
can
have only one loan outstanding at a time, which, if you're
concerned
with
counting the days between loans, is probably a very good idea to
minimize
financial risk.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and
tutorials.
Blog:
http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for
contact
info.
Scenario: I receive a loan on Jan 1 and it's due date is Jan
15,
which
gives
the loan a 14-day duration. But, then I come back for another
loan
(a
new
record "row" is created on Jan 21. How do I calculate the days
between
previous due date and the new loan date, which is 6? I am
trying
to
keep
track of how many days pass before certain customers return.
HELP!!!