34,871
社区成员




我有四个字段: 会员卡, 日期, 大分类, 次分类
大分类:贝类
次分类:蚬, 文蛤
我想统计出每个会员在哪天买了哪些商品
语法:
select cardno,date, string_agg(item, ',') within group (order by item) item,
string_agg(item1, ',') within group (order by item1) item1
from Q1
group by cardno, date
order by cardno;
执行后出现错误讯息:相同范围中的多个排序聚合函数具有彼此不兼容的排序。
该如何调整代码?
两个within group (order by cardno) 这里
是指 group by cardno, date
order by cardno, date;
結果還是一樣
你 order by 这里要一致