什麼select語句,我應該用得到如下結果:選擇在SELECT語句(連接表)SQL
目前,當我運行,下面我的存儲過程,它會顯示「結果」圖片:
select vm.ID_Vendor,vm.Vendor_Name,vpe.Company_Name,vpe.TOTAL,
vpe.COUNT,vpe.AVERAGE from VENDOR_MASTER vm
LEFT JOIN
(select vvd.ID_Vendor,sc.ID_Company,sc.Company_Name,vvd.VPE_Average_Score,
SUM(vvd.VPE_Average_Score) AS TOTAL,COUNT(vvd.VPE_Total_Score) AS COUNT,
(SUM(vvd.VPE_Average_Score)/COUNT(vvd.VPE_Total_Score)) AS AVERAGE,
vvm.Assessor_Name FROM VENDOR_VPE_MASTER vvm
left join VENDOR_VPE_DETAIL vvd on vvm.ID_VPE_Master=vvd.ID_VPE_Master
left join SETUP_COMPANY sc on vvm.ID_Company=sc.ID_Company
left join REF_EVL_RATING rer1 on vvd.Quality_Product=rer1.ID_Evl_Rating
left join REF_EVL_RATING rer2 on vvd.Service=rer2.ID_Evl_Rating
left join REF_EVL_RATING rer3 on vvd.Technical=rer3.ID_Evl_Rating
left join REF_EVL_RATING rer4 on vvd.Quality_Mgmt=rer4.ID_Evl_Rating
left join REF_EVL_RATING rer5 on vvd.Price=rer5.ID_Evl_Rating
GROUP BY vvd.ID_Vendor,sc.ID_Company,sc.Company_Name,vvd.VPE_Average_Score,
vvd.VPE_Average_Score,vvd.VPE_Total_Score,vvm.Assessor_Name) as vpe on vm.ID_Vendor=vpe.ID_Vendor
order by vpe.ID_Vendor
抱歉,這不是關於格式化電子表格或垂直書寫標題。它只是我想要的存儲過程,可以檢索我想要的結果。 –