OLAP functions are calculated after aggregation, "order by sold_date" fails because there's no more detail row, but why do you need it at all. When you just want a group count, remove it.
And the max calculation will not run in any existing RDBMs.
And "distinct" is not needed when you do a "group by", both return distinct rows.
Remove the OLAP function and try to get your query running using only group by.
Dieter
↧