按城市划分的订单数量
我的查询:
select distinct a.city,
(
select count(*)
from sales_flat_order
where a.email=b.customer_email
group by a.city
) as 'lora'
from sales_flat_order_address a, sales_flat_order b
group by a.city
结果:
City1 : 15
City2: (NULL)
预期结果:
City1 : 13
City2: 2
My Query:
select distinct a.city,
(
select count(*)
from sales_flat_order
where a.email=b.customer_email
group by a.city
) as 'lora'
from sales_flat_order_address a, sales_flat_order b
group by a.city
Result:
City1 : 15
City2: (NULL)
Expected Result:
City1 : 13
City2: 2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就是您正在寻找的东西(专为 magento 1.5 设计)吗?
编辑
需要有一个地址类型过滤器,因为每个订单都会有一个帐单和送货地址。
Is that what you are looking for (designed for magento 1.5)?
EDIT
Needed to have a filter for address type as every order will have a billing and shipping address.
可以返回多行。它不能在 SELECT 子句中用作查询字段,除非 EMAIL 字段具有某些唯一索引,例如此外,从 ANSI SQL 的角度来看,它包含语法错误。 GROUP BY 子句在这里是多余的
can return multiple rows. it can not be used in a SELECT clause as query field, unless EMAIL field has some unique index e.g. besides, it contains syntax error from a point of view of ANSI SQL. GROUP BY clause is redundand here
绑定 sales_flat_order_address a 和 sales_flat_order b 的 where 子句似乎有问题
seems problem in no where clause for binding sales_flat_order_address a and sales_flat_order b