资源描述:
《报表SQL语句整理》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、报表SQL语句整理selectdbo.fun_money2str(SUM(PurchaseAmount))PurchaseAmount,dbo.fun_money2str(SUM(DistributeAmount))DistributeAmount,dbo.fun_money2str(SUM(WarehouseAmount))WarehouseAmount,dbo.fun_money2str(SUM(PayedAmount))PayedAmount,dbo.fun_money2str(SUM(WithdrawAmount))
2、WithdrawAmount,count(DistinctDistributorID)DistributorCountfromdbo.REP_DistributorAreaMedtypedamjoinfunGetSubZoneByUID('CGZX',0)SZONdam.ZoneID=SZ.ZoneIDjoinfunGetSubMedtype('YPLY',1)gsmondam.MedicineTypeId=gsm.MedicineTypeIdwhere1=1ANDOrderYear=2012selectOrderMonth
3、,HM.MedicineTypeID,HM.MedicineTypeName,dbo.fun_money2str(SUM(PurchaseAmount))PurchaseAmount,dbo.fun_money2str(SUM(DistributeAmount))DistributeAmount,dbo.fun_money2str(SUM(WithdrawAmount))WithdrawAmountfromREP_DistributorAreaMedtypeHMjoinfunGetSubZoneByUID('CGZX',0)
4、SZONHM.ZoneID=SZ.ZoneIDjoinfunGetSubMedtype('YPLY',1)gsmonHM.MedicineTypeId=gsm.MedicineTypeIdwhere1=1ANDOrderYear=2012GROUPBYOrderMonth,HM.MedicineTypeID,HM.MedicineTypeNameorderbyOrderMonth,HM.MedicineTypeName6selectSUBSTRING(CONVERT(VARCHAR(12),OrderMonth),0,5)+
5、'年'+CONVERT(VARCHAR(2),((OrderMonth%100-1)/3+1))+'季度'ASQuarters,dam.MedicineTypeID,dam.MedicineTypeName,dbo.fun_money2str(SUM(PurchaseAmount))PurchaseAmount,dbo.fun_money2str(SUM(DistributeAmount))DistributeAmount,dbo.fun_money2str(SUM(PayedAmount))PayedAmount,dbo.
6、fun_money2str(SUM(WithdrawAmount))WithdrawAmountfromREP_DistributorAreaMedtypedamjoinfunGetSubZoneByUID('CGZX',1)SZONdam.ZoneID=SZ.ZoneIDjoinfunGetSubMedtype('YPLY',1)gsmondam.MedicineTypeId=gsm.MedicineTypeIdwhere1=1ANDOrderYear=2012GROUPBYSUBSTRING(CONVERT(VARCHA
7、R(12),OrderMonth),0,5)+'年'+CONVERT(VARCHAR(2),((OrderMonth%100-1)/3+1))+'季度',dam.MedicineTypeID,dam.MedicineTypeNameorderbyQuarters,dam.MedicineTypeName6selectOrderCount,PurchaseCount,PurchaseAmount,DistributeAmount,WarehouseCount,WarehouseAmount,PayedCount,PayedAm
8、ount,WithdrawCount,WithdrawAmount,StatisticZoneName,DistributorCount,HospitalCount,FactoryCountfrom(selectdbo.fun_money2str(SUM(PurchaseAmount))P