I changed the query from a Select Query to a Make-Table Query and created an
index in the new table after running it. I'm now trying to make a second
query that pulls from this update table. Will that work?
It is going much faster now, but now I can't get the Max function to work on
the counter...it's giving me duplicate loan numbers still when I just want
the record for each loan number with the highest count.
If it helps, here is the code for my first query (the Make-Table Query):
SELECT dbo_Q_FieldLogging.Key1, dbo_Q_FieldLogging.Counter,
dbo_Q_FieldLogging.DateChanged, dbo_Q_FieldLogging.FieldID,
dbo_Q_FieldLogging.OldValue, dbo_Q_FieldLogging.NewValue INTO T_Q_FieldLogging
FROM dbo_Q_FieldLogging
WHERE (((dbo_Q_FieldLogging.Counter)>10000000) AND
((dbo_Q_FieldLogging.FieldID)=1253))
ORDER BY dbo_Q_FieldLogging.Counter;
And here is the code for the second query:
SELECT T_LoanID.LoanID, Max(T_Q_FieldLogging.Counter) AS MaxOfCounter,
CDate([DateChanged]) AS Date_Changed, T_Q_FieldLogging.FieldID,
CDate([OldValue]) AS Old_Due, CDate([NewValue]) AS New_Due
FROM T_LoanID LEFT JOIN T_Q_FieldLogging ON T_LoanID.LoanID =
T_Q_FieldLogging.Key1
GROUP BY T_LoanID.LoanID, CDate([DateChanged]), T_Q_FieldLogging.FieldID,
CDate([OldValue]), CDate([NewValue]);
I might not be making them the proper way. I haven't been formally trained
to work with databases, so I just keep trying random things until something
finally works.
Thanks,
Michelle
Jerry Whittle said:
You can't create an index using a select query. As the table is read only, I
doubt that you could add an index using an alter or create statement either.
You probably need to talk to who owns the table and see if they can.
Where is this table located? Are you getting to it through an ODBC
connection or is it a linked table? It's possible that you might be able to
use a pass-through query if the table is in another database management
system such as SQL Server or Oracle.
How slow is it? Second? Minutes? Hours?
What is the SQL statement for the query? Open the query in design view. Next
go to View, SQL View and copy and past it here. Maybe there's a way to speed
up that query.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
:
Hello, I'm a beginner, so I don't know if this is possible. I have a query
that is pulling data from a read-only table. The two fields that I'm using
are a loan number field and a counter field. There are duplicate loan
numbers, but every record in the counter is unique. I used the Maximum
function to get the maximum count number for each loan. It works, but it goes
very slow.
I thought I could speed it up if I created an index for the loan number.
But, since the table I'm pulling from is read-only, can I do it in the query
instead?
Thanks,
Michelle