楼上的,你试过了吗? 这样做不行呢,会出现下面的错误. Group by 后面好像一定要跟一个字段. Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
因为身边没有机器,所以不好测试. 这个你再试试,需要mysql4.1以上,支持子查询的select DATE_FORMAT(OrderDate ,'%Y-%c-%e') as dd ,sum(Qty) from yourtable where dd in (select DATE_FORMAT(OrderDate ,'%Y-%c-%e') from yourtable);
楼上的,也不行啦,错误:Unknown column 'dd' in 'scalar IN/ALL/ANY subquery'
我的版本已经是ver 4.1.7 了
to: trainee(春泥) 你说的这段代码可以吗?select DATE_FORMAT(OrderDate ,'%Y-%c-%e') as dd ,sum(Qty) from yourtable where dd in (select DATE_FORMAT(OrderDate ,'%Y-%c-%e') from yourtable);
找到方法了. 应该这样select DATE_FORMAT(OrderDate ,'%Y-%c-%e') as dd ,sum(Qty) from yourtable group by DATE_FORMAT(OrderDate ,'%Y-%c-%e')
Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
这个你再试试,需要mysql4.1以上,支持子查询的select DATE_FORMAT(OrderDate ,'%Y-%c-%e') as dd ,sum(Qty) from yourtable where dd in (select DATE_FORMAT(OrderDate ,'%Y-%c-%e') from yourtable);
group by DATE_FORMAT(OrderDate ,'%Y-%c-%e')