select
STATISTICAL_DATE
,PROVINCE_NAME
,STANDARD_CITY_NAME
,COUNTY_NAME
,BIZ_NAME
,ITEMNAMENEW
,ONE_DIMENSION_NAME
,TWO_DIMENSION_NAME
,sum(CYCM_AV_PRM)
,sum(CYCM_TG_PRM)
,sum(CYCM_CHARHB_BASED)
,sum(CYCM_AV_QTY)
,COALESCE(SUM(COALESCE(CYCM_CHARHB,0)) / NULLIF(SUM(COALESCE(CYCM_AV_PRM_EX,0)),0),0)
,COALESCE(SUM(COALESCE(CYCM_AV_PRM_TAX_Y,0)) / NULLIF(SUM(COALESCE(CYCM_DUTY_LIMIT_AC_Y,0)),0),0)
,avg(CYCM_COMPENSATERATE_R)
,sum(CY_AV_PRM)
,sum(CY_TG_PRM)
,sum(CY_CHARHB_BASED)
,sum(CY_AV_QTY)
,COALESCE(SUM(COALESCE(CY_CHARHB,0)) / NULLIF(SUM(COALESCE(CY_AV_PRM_EX,0)),0),0)
,COALESCE(SUM(COALESCE(CY_AV_PRM_TAX_Y,0)) / NULLIF(SUM(COALESCE(CY_DUTY_LIMIT_AC_Y,0)),0),0)
,avg(CY_COMPENSATERATE_R)
,sum(LYCM_AV_PRM)
,sum(LYCM_TG_PRM)
,sum(LYCM_CHARHB_BASED)
,sum(LYCM_AV_QTY)
这是我的sql语句,你可以试试
除了日期是date类型,地区是字符外,其他都是数值型 |