DB Query Reader - ORDER BY DESC

Hello dear group, can you help me with this error.

Example:

SELECT
CAMPO01,
CAMPO02,
CAMPO03
FROM TABLA01 ORDER BY CAMPO02 DESC

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

Regards,

Hi @Gfranco2021
Can you please show us your configuration and errors so we can understand better what is happening. Is it ORACLE, SQL SERVER, POSTGRES ?

You can absolutely use an ORDER BY clause in a SQL statement. Please give us some more information so we can help you.

2 Likes

Hi @eamendola,

My problem is that I had a client with 4 records, but I only wanted to filter the last record. I thought I could achieve it with ORDER BY DESC, however, I achieved my goal with a MAX and a GROUP BY.

Anyway thank you very much.

Regards.

@Gfranco2021 you could see if your database world support Window functions like RANK that could give you more control which entry you would like to see returned

Excellent @mlauber71, thank you very much for the shared information.
I am sure it will be very useful.

Regards.

1 Like

I sometimes do SELECT TOP 100% foo, bar FROM …

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