查询到的数据插入到临时表 #1 我用select * into #1 from ( select a.yzmc as 名称,sum(a.zl) as 数量 ,sum(a.je) as 金额 ,b.mc as 科室 from zy_bhjfyz201303 a,zd_ks b where a.ksbm=b.bm and a.fylb in (87,88,99,100) and a.rq between 41326 and 41353 and a.flag& 16=0 and a.flag & 2>0 group by a.yzmc,a.ksbm,b.mc) 提示 “消息 170,级别 15,状态 1,第 1 行
第 1 行: ')' 附近有语法错误。
”
2 个解决方案
#1
SELECT *
INTO #1
FROM ( SELECT a.yzmc AS 名称 ,
SUM(a.zl) AS 数量 ,
SUM(a.je) AS 金额 ,
b.mc AS 科室
FROM zy_bhjfyz201303 a ,
zd_ks b
WHERE a.ksbm = b.bm
AND a.fylb IN ( 87, 88, 99, 100 )
AND a.rq BETWEEN 41326 AND 41353
AND a.flag & 16 = 0
AND a.flag & 2 > 0
GROUP BY a.yzmc ,
a.ksbm ,
b.mc
) T --这里
#2
select * into #1 from
( select a.yzmc as 名称,sum(a.zl) as 数量 ,sum(a.je) as 金额 ,b.mc as 科室 from zy_bhjfyz201303 a,zd_ks b where a.ksbm=b.bm and a.fylb in (87,88,99,100) and a.rq between 41326 and 41353 and a.flag& 16=0 and a.flag & 2>0 group by a.yzmc,a.ksbm,b.mc)
t
( select a.yzmc as 名称,sum(a.zl) as 数量 ,sum(a.je) as 金额 ,b.mc as 科室 from zy_bhjfyz201303 a,zd_ks b where a.ksbm=b.bm and a.fylb in (87,88,99,100) and a.rq between 41326 and 41353 and a.flag& 16=0 and a.flag & 2>0 group by a.yzmc,a.ksbm,b.mc)
t
#1
SELECT *
INTO #1
FROM ( SELECT a.yzmc AS 名称 ,
SUM(a.zl) AS 数量 ,
SUM(a.je) AS 金额 ,
b.mc AS 科室
FROM zy_bhjfyz201303 a ,
zd_ks b
WHERE a.ksbm = b.bm
AND a.fylb IN ( 87, 88, 99, 100 )
AND a.rq BETWEEN 41326 AND 41353
AND a.flag & 16 = 0
AND a.flag & 2 > 0
GROUP BY a.yzmc ,
a.ksbm ,
b.mc
) T --这里
#2
select * into #1 from
( select a.yzmc as 名称,sum(a.zl) as 数量 ,sum(a.je) as 金额 ,b.mc as 科室 from zy_bhjfyz201303 a,zd_ks b where a.ksbm=b.bm and a.fylb in (87,88,99,100) and a.rq between 41326 and 41353 and a.flag& 16=0 and a.flag & 2>0 group by a.yzmc,a.ksbm,b.mc)
t
( select a.yzmc as 名称,sum(a.zl) as 数量 ,sum(a.je) as 金额 ,b.mc as 科室 from zy_bhjfyz201303 a,zd_ks b where a.ksbm=b.bm and a.fylb in (87,88,99,100) and a.rq between 41326 and 41353 and a.flag& 16=0 and a.flag & 2>0 group by a.yzmc,a.ksbm,b.mc)
t