Skip to Content
0
Former Member
Nov 15, 2016 at 03:10 PM

Query for most ordered products

145 Views

Hi , we were working on a query to find the most ordered products in descending order but however query is not working and giving missing '}' for '{' error. Could someone please suggest solutions. Here is the query:

select {p1:code} from {Myproduct as p1} join {SELECT {P.CODE} as p1code,COUNT({P.code}) as tcount FROM { order AS O JOIN orderentry AS OE ON {OE.order} = {O.pk} JOIN Myproduct AS P ON {OE.product} = {P.pk} }
GROUP BY {P.CODE}} as p2 on {p2:p1code}={p1:code} order by {p2.tcount} desc