我需要使用ADO查询从现有表上的查询中创建一个新表。
DB是MS Access2003。是否有简单的方法可以重新创建它?
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);
最佳答案
要通过对现有表的查询来创建新表,可以使用SELECT INTO
(创建新表)或INSERT INTO SELECT
(插入现有表)语句。
检查this MSDN页,其中有您需要的漂亮示例。