/*正局級(jí)干部醫(yī)療費(fèi)報(bào)銷(xiāo)明細(xì)表sql腳本*/
select * from (
select a.社保編碼,a.姓名,門(mén)診醫(yī)療費(fèi),住院醫(yī)療費(fèi),基本醫(yī)療費(fèi),住院補(bǔ)充保險(xiǎn)三報(bào)銷(xiāo),公務(wù)員住院醫(yī)療補(bǔ)助,正局級(jí)醫(yī)療補(bǔ)助? from (
select toa_3879_20150507160842 as 社保編碼,
toa_8683_20150507160906 as 姓名,
sum(toa_1253_20150507161405) as 門(mén)診醫(yī)療費(fèi),
sum(toa_4899_20150507161746) as 基本醫(yī)療費(fèi)
from toa_wd_8892
group by toa_3879_20150507160842, toa_8683_20150507160906
) as a
left join (
select? toa_6605_20150507170717 as 社保編碼,
toa_0180_20150507170753 as 姓名,
sum(toa_8625_20150507170834) as 住院醫(yī)療費(fèi),
sum(toa_3504_20150507173835) as 住院補(bǔ)充保險(xiǎn)三報(bào)銷(xiāo),
sum(toa_1508_20150507173910) as 公務(wù)員住院醫(yī)療補(bǔ)助,
sum(toa_3030_20150507173930) as 正局級(jí)醫(yī)療補(bǔ)助
from toa_wd_8893
group by toa_6605_20150507170717, toa_0180_20150507170753
) as b
on a.社保編碼=b.社保編碼
union
select b.社保編碼,b.姓名,門(mén)診醫(yī)療費(fèi),住院醫(yī)療費(fèi),基本醫(yī)療費(fèi),住院補(bǔ)充保險(xiǎn)三報(bào)銷(xiāo),公務(wù)員住院醫(yī)療補(bǔ)助,正局級(jí)醫(yī)療補(bǔ)助? from (
select toa_3879_20150507160842 as 社保編碼,
toa_8683_20150507160906 as 姓名,
sum(toa_1253_20150507161405) as 門(mén)診醫(yī)療費(fèi),
sum(toa_4899_20150507161746) as 基本醫(yī)療費(fèi)
from toa_wd_8892
group by toa_3879_20150507160842, toa_8683_20150507160906
) as a
right join (
select? toa_6605_20150507170717 as 社保編碼,
toa_0180_20150507170753 as 姓名,
sum(toa_8625_20150507170834) as 住院醫(yī)療費(fèi),
sum(toa_3504_20150507173835) as 住院補(bǔ)充保險(xiǎn)三報(bào)銷(xiāo),
sum(toa_1508_20150507173910) as 公務(wù)員住院醫(yī)療補(bǔ)助,
sum(toa_3030_20150507173930) as 正局級(jí)醫(yī)療補(bǔ)助
from toa_wd_8893
group by toa_6605_20150507170717, toa_0180_20150507170753
) as b
on a.社保編碼=b.社保編碼) as c limit 0,2;