在"组中获取错误错误:SELECT列表表达式引用列id_coupon既不是分组也不是聚合在... "
在我的表格中#34; table_name" id_coupon为每个id_discount都有多个条目。意味着id_discount不是唯一的,id_coupon是唯一的。我想只针对每个id_discount获得一个id_coupon ...
SELECT
id_discount,
id_coupon
FROM
abbccc.discounts.table_name
GROUP BY id_discount
答案 0 :(得分:3)
SELECT
id_discount,
MIN(id_coupon) as id_coupon
FROM abbccc.discounts.table_name
GROUP BY id_discount