SELECT CARD_TYPE,TASK.CITYCODE,CITYNAME AS cityName,sum(VALID_COUNT) AS validCount,sum(INVALID_COUNT) AS invalidCount,COUNT(GROUP_NO) AS groupCount,GROUP_NO AS groupNo,TASK.TASK_ID,OLD_CARD_TYPE,SUBMIT_DATE,ISSUED_DATE,PRINT_STATE,DOWNLOAD_DATE,PRINT_OUT_DATE,POSITION_DATE,OUT_WORKSHOP_DATE,QUALITY_PEOPLE_NAME,QUALITY_TEST_DATE,EXCEPTION_INFORMATION,OUT_STORAGE_DATE,IN_STORAGE_DATE,TASK_STATE_ID,IS_EXCEPTION,PRINTER_ID from (select sum(VALID_COUNT),sum(INVALID_COUNT),COUNT(GROUP_NO),TASK_ID,GROUP_NO,SPECIAL_CARD_COUNT,VALID_COUNT,INVALID_COUNT from GROUP_NO group by TASK_ID,GROUP_NO,SPECIAL_CARD_COUNT,VALID_COUNT,INVALID_COUNT ) GROUP_NO
SELECT CARD_TYPE AS cardType,TASK.CITYCODE AS citycode,CITYNAME AS cityName,sum(VALID_COUNT) AS validCount,sum(INVALID_COUNT) AS invalidCount,COUNT(GROUP_NO) AS groupCount,GROUP_NO AS groupNo,TASK.TASK_ID AS taskId,OLD_CARD_TYPE AS oldCardType,SUBMIT_DATE AS submitDate,ISSUED_DATE AS issuedDate,PRINT_STATE AS printState,DOWNLOAD_DATE AS downloadDate,PRINT_OUT_DATE AS printOutDate,POSITION_DATE AS positionDate,OUT_WORKSHOP_DATE AS outWorkshopDate,QUALITY_PEOPLE_NAME AS qualityPeopleName,QUALITY_TEST_DATE AS qualityTestDate,EXCEPTION_INFORMATION AS exceptionInformation,OUT_STORAGE_DATE AS outStorageDate,IN_STORAGE_DATE AS inStorageDate,TASK_STATE_ID AS taskStateId,IS_EXCEPTION AS isException,PRINTER_ID AS printerId
from (select sum(VALID_COUNT),sum(INVALID_COUNT),COUNT(GROUP_NO),TASK_ID,GROUP_NO,SPECIAL_CARD_COUNT,VALID_COUNT,INVALID_COUNT from GROUP_NO group by TASK_ID,GROUP_NO,SPECIAL_CARD_COUNT,VALID_COUNT,INVALID_COUNT ) GROUP_NO
left join TASK on GROUP_NO.TASK_ID = TASK.TASK_ID
left join (SELECT CITYCODE,CITYNAME FROM CITY_DIC) CITY_DIC on CITY_DIC.CITYCODE = TASK.CITYCODE
where CARD_TYPE=#{cardType} and TASK_STATE_ID = #{taskStateId}