Patty-
You never said why your original query wouldn't export:
SELECT wo_master_IM3_elig_Enc.*
FROM wo_master_IM3_elig_Enc INNER JOIN (SELECT person_id, MAX(modify_timestamp) AS TimeMatch FROM wo_master_IM3_elig_Enc GROUP BY person_id) AS MaxRecord ON (wo_master_IM3_elig_Enc.modify_timestamp = MaxRecord.TimeMatch) AND (wo_master_IM3_elig_Enc.person_id = MaxRecord.person_id);
FROM wo_master_IM3_elig_Enc INNER JOIN (SELECT person_id, MAX(modify_timestamp) AS TimeMatch FROM wo_master_IM3_elig_Enc GROUP BY person_id) AS MaxRecord ON (wo_master_IM3_elig_Enc.modify_timestamp = MaxRecord.TimeMatch) AND (wo_master_IM3_elig_Enc.person_id = MaxRecord.person_id);
Trying to do it with the subquery in the WHERE clause is probably what's causing the "too many databases open" error. The Excel export is stupid - it's probably creating a new connection for the subquery on EVERY row!
The only other alternative that comes to mind is to turn your original query into a Make Table, then export the resulting table.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jul 6, 2016, at 4:44 PM, pattykf@cox.net [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
I changed the modified to an index field with yes there can be duplicates and that still did not resolve the issue of exporting the query to excel. I still get too many databases open. I thought maybe it was a field I had added so removed that field from all the queries that might be linked to the final query and it still did not resolve it.
the table is an exported table from our electronic health record, so I had to modify it on my imported version since I do not work on the "live" electronic health record tables.
Ideas for this issue. It was working so I can not figure out why it would stop working
thank you
patty.
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Patty-
so do i create a different query to add the index to the modify_timestamp or can I index it in my last query?, I have not tried that before so want to make sure i do it correctly
thank you so much
Patty
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
The index is in the table definition, not the query.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jul 5, 2016, at 4:22 PM, pattykf@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
so do i create a different query to add the index to the modify_timestamp or can I index it in my last query?, I have not tried that before so want to make sure i do it correctly
thank you so much
Patty
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Patty-
the master Im table currently has over 500,000 rows of data and growing. Modify timestamp could be the same for different patients would that matter in creating an index on modify_timestamp?
thank you
Patty
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Doesn't matter if there are duplicates - an index might help.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jul 5, 2016, at 3:53 PM, pattykf@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
the master Im table currently has over 500,000 rows of data and growing. Modify timestamp could be the same for different patients would that matter in creating an index on modify_timestamp?
thank you
Patty
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Patty-
thank you John,
I gave it a shot, it appeared to run through the query (bar moved on the bottom) but then the sql screen went blank and the mouse hover is just spinning. It appears stuck?
thankx
Patty
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
That query should run slower than your original. How many rows are you exporting? How big is the wo_master table?
I assume you have an index on person_id. It might run faster with an index on modify_timestamp.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jun 28, 2016, at 9:22 PM, pattykf@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
thank you John,
I gave it a shot, it appeared to run through the query (bar moved on the bottom) but then the sql screen went blank and the mouse hover is just spinning. It appears stuck?
thankx
Patty
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Patty-
I have a query which will not export to excel. I have been able to export the one that was created that pulled in all the patients but this one that limits the patients to the last encounter will not export. IDEAS?
SELECT wo_master_IM3_elig_Enc.*
FROM wo_master_IM3_elig_Enc INNER JOIN (SELECT person_id, MAX(modify_timestamp) AS TimeMatch FROM wo_master_IM3_elig_Enc GROUP BY person_id) AS MaxRecord ON (wo_master_IM3_elig_Enc.modify_timestamp = MaxRecord.TimeMatch) AND (wo_master_IM3_elig_Enc.person_id = MaxRecord.person_id);
Try this:
SELECT W1.*
FROM wo_master_IM3_Elig_enc AS W1
WHERE modify_timestamp =
(SELECT MAX(modify_timestamp) FROM wo_master_IM3_elig_Enc AS W2
WHERE W2.person_id = W1.person_id);
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Jun 28, 2016, at 8:26 PM, pattykf@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
I have a query which will not export to excel. I have been able to export the one that was created that pulled in all the patients but this one that limits the patients to the last encounter will not export. IDEAS?
SELECT wo_master_IM3_elig_Enc.*
FROM wo_master_IM3_elig_Enc INNER JOIN (SELECT person_id, MAX(modify_timestamp) AS TimeMatch FROM wo_master_IM3_elig_Enc GROUP BY person_id) AS MaxRecord ON (wo_master_IM3_elig_Enc.modify_timestamp = MaxRecord.TimeMatch) AND (wo_master_IM3_elig_Enc.person_id = MaxRecord.person_id);
__._,_.___
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (11) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar