This is a cary-over from this thread:
Run Query based off Table selected from Combo Box
Info about database/tables: I have a database (Access 2013) with a table in it that stores a history of Knowledgebase article view statistics. There is a snapshot of Total (lifetime) Views taken each month and that data is added to the table with the appropriate month & year tag (2 separate fields: MonthNum & Year).
I have the following query (thx to help from jforbes) titled qryMonthlyViews that calculates the Monthly Views (calculating the difference in views from month-to-month):
I then wrote the following two statements to create a new table (qryCreateTable) and import the data from the query to the new table (qryImportViewDa ta):
Where I'm stuck is, I don't know how I would write the query that would total the last 3 months. Can anyone help on this?
Thank you in advance!
Run Query based off Table selected from Combo Box
Info about database/tables: I have a database (Access 2013) with a table in it that stores a history of Knowledgebase article view statistics. There is a snapshot of Total (lifetime) Views taken each month and that data is added to the table with the appropriate month & year tag (2 separate fields: MonthNum & Year).
I have the following query (thx to help from jforbes) titled qryMonthlyViews that calculates the Monthly Views (calculating the difference in views from month-to-month):
Code:
SELECT [KB_History].[Total Views]-[Previous].[Total Views] AS MonthlyViews , KB_History.[Total Views] , KB_History.[Article Number] , KB_History.Title , KB_History.[Version Number] , KB_History.[Created Date] , KB_History.[Last Modified Date] , KB_History.[Created By: Full Name] , KB_History.[Last Modified By: Full Name] , KB_History.MonthNum , KB_History.Year FROM KB_History LEFT JOIN KB_History AS Previous ON (KB_History.MonthNumber-1 = Previous.MonthNumber) AND (KB_History.[Article Number] = Previous.[Article Number]);
Code:
CREATE TABLE tblMonthlyViews ( MonthlyViews INTEGER, [Total Views] INTEGER, [Article Number] CHAR(255), [Title] CHAR(255), [Version Number] INTEGER, [Created Date] DATE, [Last Modified Date] DATE, [Created By: Full Name] CHAR(255), [Last Modified By: Full Name] CHAR(255), MonthNum INTEGER, Year INTEGER);
Code:
SELECT * INTO tblMonthlyViews FROM qryMonthlyViews;
Thank you in advance!
Comment