Sql postgres统计有2个或更多订单的客户
我需要得到每月2个或更多订单的客户数量。我对postgresql不是很在行,所以任何帮助都将不胜感激 表名为shop_orders 相关列为“电子邮件”-客户,“状态代码”的值应为“已确认”,日期-时间戳 谢谢。试试这个:Sql postgres统计有2个或更多订单的客户,sql,postgresql,Sql,Postgresql,我需要得到每月2个或更多订单的客户数量。我对postgresql不是很在行,所以任何帮助都将不胜感激 表名为shop_orders 相关列为“电子邮件”-客户,“状态代码”的值应为“已确认”,日期-时间戳 谢谢。试试这个: select EXTRACT(month FROM datecolumn ) as month,email from shop_orders where status_code = 'CONFIRMED' group by EXTRACT(month FROM datecol
select EXTRACT(month FROM datecolumn ) as month,email
from shop_orders
where status_code = 'CONFIRMED'
group by EXTRACT(month FROM datecolumn ),email
having count(1) >2
看起来不错,但我想知道如何返回每个月的数字数组。不过还是要谢谢你。@user3729867我已经添加了月刊专栏谢谢你,那会有用的。@user3729867我很高兴能帮助你