SQL - Perform ORDR BY SUM(col1*col2)

Hi

I am willing to execute this query, retreive the top products with haghiest value:

SELECT ID_PROD, SUM(PRICE*VOLUME) AS **VALUE** FROM sales group by ID_PROD ORDER BY VALUE

I receive this error:

{
  "message": "Client request error: Parse Error",
  "statusCode": 502,
  "error": "Bad Gateway"
}

it works when I try this one:
SELECT ID_PROD, PRICE FROM sales ORDER BY PRICE

How can I perform this kind of queries?

Thanks

@yamaga What ES version are you using? This is supported starting with ES 7.8.0.
Also, the error you posted there is not ES SQL specific. "Bad Gateway" is a http error that probably comes from a intermediary system that sits between the client using the ES service and ES.

It works when I added DESC after ORDER BY

SELECT ID_PROD, SUM(PRICE*VOLUME) AS **VALUE** FROM sales group by ID_PROD ORDER BY VALUE **DESC**

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.