在加入两个表时,我执行了一个查询,但它没有正确显示第二个表数据,而是显示垃圾值..
我使用的查询是,
select p.machinenumber,
max(case when (p.shift)=1 then xxxx end) s1_xxxx,
max(case when (p.shift)=2 then xxxx end) s2_xxxx,
avg(case when (p.shift)=1 then yyyy end) s1_yyyy ,
avg(case when (p.shift)=2 then yyyy end) s2_yyyy
from pdata p
inner join (select count(case when (shift)=1 and (ename)=1 then ename end) s1_wa,
count(case when (shift)=1 and (ename)=2 then errorname end) s1_we,
count(case when (shift)=2 and (ename)=1 then errorname end) s2_wa,
count(case when (shift)=2 and (ename)=2 then ename end) s2_we,
count(case when (shift)=1 and (ename)=0 then ename end) s1_merror,
count(case when (shift)=2 and (ename)=0 then ename end) s2_merror from mstop)m
on p.mnumber=m.mnumber
where date(p.proddate)='2013-02-25';
请解决这个问题??