Reputation: 301
I need to CREATE a new table from a query on existing tables using ADO query. DB is MS Access 2003. Is there a simple way to recreate this?
DROP TABLE IF EXISTS tmp_report;
CREATE TABLE tmp_report
SELECT Userid, Name,
DATE(CheckTime) AS date,
MIN(CheckTime) AS first_login,
MAX(checktime) AS last_login,
COUNT(CheckTime) AS No_logins,
IF(COUNT(CheckTime) = 1, 'ERROR',
TIME_TO_SEC(TIMEDIFF(max(checktime), min(CheckTime))) AS total_sec
FROM
Checkinout LEFT JOIN Userinfo USING(Userid)
GROUP BY
Userid, DATE(CheckTime)
ORDER BY
Userid, DATE(CheckTime);
Upvotes: 2
Views: 4609
Reputation: 7187
To CREATE a new table from a query on existing tables, you can use SELECT INTO
(this creates a new table) or INSERT INTO SELECT
(this inserts into an existing table) statements.
Check this MSDN page, it has nice examples that you need.
Upvotes: 3