我有一份报告显示基于用户的交易计数,关税计划的操作类型和交易状态。什么是最好的方法来做到这一点。 IS多组可能和可行吗?
示例数据和输出:
Date Plan Total USer Type of operation status product
2/8/2017 Entel Prepago Smart 5 01234567 Venta Success sim
2/8/2017 Super Plan 3 01234568 Venta Success pack
2/8/2017 Entel Prepago Smart 1 01234567 Venta Cancel sim
2/8/2017 Super Plan 1 01234568 Venta Cancel sim
2/8/2017 Entel Prepago 2 01234567 Reposicion Cancel sim
2/9/2017 Entel Prepago 10 01234570 Portabilidad Success pack
2/9/2017 Entel Prepago Smart 1 01234567 Venta Pending pack
2/9/2017 Super Plan 1 01234568 Portabilidad Success sim
答案 0 :(得分:0)
是的,您可以多个分组。
您可以尝试以下查询:
SELECT COUNT(transaction), user, tariff_plan, status FROM your_table GROUP BY user, tariff_plan, status
答案 1 :(得分:0)
试试这个:
select
user, plan, type_of_operation, status,
count(*) cnt
from your_table
group by
user, plan, type_of_operation, status;