加入3个或更多表格并总结这些字段
答
你并不需要加入tblwork
,你可以得到从其他2所有必填字段表。
以下查询应该工作:
select t1.nmstudent,
sum(case when t2.idwork = 'w001' then t2.trprice else 0 end) as w001,
sum(case when t2.idwork = 'w002' then t2.trprice else 0 end) as w002,
sum(case when t2.idwork = 'w003' then t2.trprice else 0 end) as w003,
sum(case when t2.idwork = 'w004' then t2.trprice else 0 end) as w004
from tblstudent t1
inner join tblTrans t2
on t1.idstudent = t2.idstudent
group by t1.idstudent;
希望它能帮助!
你尝试过什么吗?或者只是想让我们写你的代码并做你的功课? – nacho
我已经使用colasce(),但是我需要在该colasce中添加更多条件,以便可以得到附加的结果,如果可以帮忙的话? – SETYO
这里的大多数人想要格式化文本,而不是图像。 (或者,更糟的是,链接到图像。) – jarlh