'How to show the combinations of a column in SQL along with the aggregated results?

The question is on SQL: Create a summary table to show how many customers use different GO-JEK services in a daily basis, along with the combination of services used (Please see below screenshot for more details).

Several conditions for this task:

  • Take only order_status = “Completed”
  • No repetition on details of order_type
    • You can combine it in any order but every combination is only allowed once. E.g. same combinations like RIDE, CAR, SEND and CAR, RIDE, SEND are unacceptable
  • Group each order_payment and its combination
    • I.e. aggregations by CASH, GOPAY, CASH&GOPAY (ALL)
  • Use date in UTC timezone

Dataset sample: link

enter image description here

I'm not sure on getting the order_type combinations. Please suggest.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source