IT序号网

MySQL的Date()函数拼接

luoye 2021年06月14日 数据库 303 0
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) 

评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!