Order by issue in PrestoDB


I am using Presto with Helical Insight 4.0. When I have distinct function applied on the columns, order by or sorting does not work and generates incorrect SQL. Below is a snapshot of the output and also the SQL query that is generated. Please help correct this issue.

The SQL produced is as below:


        "Distinct_Visitors"."browser"  **as**  "Browsers",

       "Distinct_Visitors"."distinct_visitors"  **as**  "Distinct Visitors" ,dense_rank()  over( **order**   **by**  "Distinct_Visitors"."browser"  **asc**  )  **as**  rownum 

**from**  (


             count( **distinct**  visitorid)  **as**  distinct_visitors,

             browser  **from**  hive.matomo_demo_prod.dive_zone_dataset  **group**   **by** browser

     )  "Distinct_Visitors"

**order**   **by**


        "Distinct Visitors"


Thank You

1 Like

Hello Tarun,

The js file for the database in the sqlFunctions folder is responsible for generation of correct SQL queries.

Please download this presto.js file and place it in the location


After this, clear the cache and try in a private window to see the result. The output will have sorting working in the correct manner for the report.

Thank You
From Team Helical