老师,你好,我按照你的说发,去查询,也只能查询到表头,后来我发现我把查询的SQL语句写简单点就能查出值来。这是为什么
复杂语句不行
SELECT f.利润中心, f.员工姓名, Sum(f.补助) AS 补助, Sum(f.长途交通) AS 长途交通, Sum(f.出租车) AS 出租车, Sum(f.公交地铁) AS 公交地铁, Sum(f.机票) AS 机票, Sum(f.住宿) AS 住宿
FROM (SELECT corp_name,period, mid(subj_name,1,instr(subj_name,'/')-1) AS 利润中心 , mid(subj_name,instr(subj_name,'/')+1) AS 员工姓名 , iif(subj_no = '6601.07.06',jfs,0) AS 补助 , iif(subj_no = '6601.07.03',jfs,0) AS 长途交通 , iif(subj_no = '6601.07.04',jfs,0) AS 出租车 , iif(subj_no = '6601.07.05',jfs,0) AS 公交地铁 , iif(subj_no = '6601.07.02',jfs,0) AS 机票 , iif(subj_no = '6601.07.01',jfs,0) AS 住宿 FROM ye_b AS b WHERE b.subj_no like '6601.07*' and b.subj_name not in ('差旅费','住宿费','机票款','高铁/长途汽车','的士/出租车','公交/地铁','补贴') union all SELECT corp_name,period, mid(subj_name,1,instr(subj_name,'/')-1) AS 利润中心 , mid(subj_name,instr(subj_name,'/')+1) AS 员工姓名 , iif(subj_no = '6602.07.06',jfs,0) AS 补助 , iif(subj_no = '6602.07.02',jfs,0) AS 长途交通 , iif(subj_no = '6602.07.04',jfs,0) AS 出租车 , iif(subj_no = '6602.07.05',jfs,0) AS 公交地铁 , iif(subj_no = '6602.07.03',jfs,0) AS 机票 , iif(subj_no = '6602.07.01',jfs,0) AS 住宿 FROM ye_b AS b WHERE b.subj_no like '6602.07*' and b.subj_name not in ('差旅费','住宿费','机票款','高铁/长途汽车','的士/出租车','公交/地铁','补贴') ) AS f
WHERE (((f.补助+f.长途交通+f.出租车+f.公交地铁+f.机票+f.住宿)<>0) And ((f.corp_name)='金业文化传播有限公司') And ((f.period)='04'))
GROUP BY f.利润中心, f.员工姓名
ORDER BY f.员工姓名;
简单语句可以
SELECT * from ye_b where period='01' and corp_name= '金业文化传播有限公司' |