Full Version: Write Results Of Group By Query To New Table
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
bntringa
Hey all,

Is there an easy way to write the results of a groupby query to a field in a different (unrelated) table as follows:

SELECT COUNT(ID) FROM tblTest

- Take this result value and write to a field called RecordCount in another table called tblSummary.

Something like:
UPDATE tblSummary SET RecordCount = (SELECT COUNT(ID) FROM tblTest)

Except that this does not work...

Thanks!
theDBguy
Hi,

Can you tell us why you need to do this? Are you updating a record or actually creating a new table?

Just my 2 cents... 2cents.gif
bntringa
Sure... I am doing alot of analytics against multiple tables and essentially consolidating the summary numbers into a singler Summary table so I can design a report against the summary numbers. I've found that because of the multitude of "slices", it's easier to automate all the queries beforehand to gather the results and then design a single report against the resultset.
theDBguy
Okay, thanks for the additional information. So, if you want to create a temporary table from the recordcount, then you could try this:

SELECT Count(*) INTO TempTableName FROM tblTest

Or, if you want to update a record in a temptable with the new record count, you could try this:

UPDATE TempTableName SET FieldName = DCount("*", "tblTest")

Just my 2 cents... 2cents.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.