cn.Execute "IF OBJECT_ID('tempdb..#a') IS NOT NULL DROP TABLE #a"
cn.Execute "select IDENTITY (int, 1, 1) as ID,车间,系统,设备,sum(运行时间) as [累计时间(分钟)],count(*) as 累计次数 into #a from run run1 where run1.车间=run.车间 and run1.系统=run.系统 and run1.设备=run.设备 order by 设备 asc"
请高手指点为什么我这么写运行的时候提示“列前缀"run"与查询中所有的表名或别名不匹配。 我再数据库中有RUN这个表的。
cn.Execute "select IDENTITY (int, 1, 1) as ID,车间,系统,设备,sum(运行时间) as [累计时间(分钟)],count(*) as 累计次数 into #a from run run1 where run1.车间=run.车间 and run1.系统=run.系统 and run1.设备=run.设备 order by 设备 asc"
请高手指点为什么我这么写运行的时候提示“列前缀"run"与查询中所有的表名或别名不匹配。 我再数据库中有RUN这个表的。
你已经把run 改名为 run1了
into #a from run run1 join run on run.id=run1.id where run1.车间=run.车间 and run1.系统=run.系统 and run1.设备=run.设备 order by 设备 asc