query extracting over over 40,000,000 records

YANECKC

Board Regular
Joined
Jun 13, 2002
Messages
199
I have a query extracting information from three tables.
Table1 has 21,000 security numbers
Table2 has 50,000,000 security numbers and account numbers
Table3 has a OCCD field for each account number
Problem is after extracting the information there is over 40,000,000 records coming back.
The query keeps freezing on me. How can I run a query that only returns the subtotals for each OCCD field ? Meaning the new query should come back and tell me how many accounts for each OCCD.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
hopefully its a simple as
Code:
select 
   [OCCD code], 
   count([Account number]) as CountOfAccountNumber
from 
  Table3
group by 
   [OCCD code]
but could take some time if those fields aren't indexed
 
Upvote 0
My problem is first i have to extract from Table2 records that match the 21,000 security numbers and get the account numbers from Table2, which will be over 20,000,000 records . too large for output in a table for microsoft 2gig limit. Then from the account numbers on Table2 that the Securities appear in table1 i have to get the oocd codes from table3. That is why i only want the subtotals lines to come back.

Meaning the new query should come back and tell me how many accounts for each OCCD where the securities were match on Table1 and the accounts and securites were matched on table2.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top