SELECT
date_format(DATE(a.date_created),'%Y-%c-%d') As dateCreate,
SUM(a.sm) As sumAmount,
sum(orderCount) as countSum
FROM
(SELECT
date_created,
sum(amount) AS sm,
count(id) AS orderCount
FROM
orders
WHERE
date_created BETWEEN CONCAT(DATE(date_created),' ','00:00:00') AND CONCAT(DATE(date_created),' ','23:59:59')
AND STATUS = 8
AND orders.order_type = #{orderType,jdbcType=INTEGER}
AND orders.supplier_party_id = #{currentPartyId,jdbcType=BIGINT}
GROUP BY
date_created
ORDER BY
date_created ASC
) a
GROUP BY DATE(a.date_created)