CREATE new TABLE from a query on another TABLE using ADO

浪尽此生 提交于 2019-12-07 22:19:52

问题


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);

回答1:


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.



来源:https://stackoverflow.com/questions/6403729/create-new-table-from-a-query-on-another-table-using-ado

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!