0
id order_id coupon_code coupon_amount
1 100 abc123 50
2 101 abc123 50
3 102 bca412 100
und meine Frage istmysql get Zeilenwerte mit Gruppe von
SELECT `coupon_code`, `order_id`,
SUM(`coupon_amount`) AS `total`,
COUNT(`id`) as `totRow`
FROM `orders`
WHERE `coupon_code`!=''
GROUP BY `coupon_code`
und soll meine Ausgabe seines
coupon code Usage Total Order Id(s)
abc123 2 100 100, 101
bca412 1 100 102
Wie alle Aufträge-IDs durch Komma in einzelner Abfrage getrennt zu bekommen?
Dank
'SELECT GROUP_CONCAT (DISTINCT order_id) als order_ids, ...' –
Ich weiß nicht, über die MySQL, aber in Oracle kann es geschehen mit LISTAGG, wenn es hilft: http://tech.pranavmaniar.in/oracle-aggregate-string-into-csv/ –