I have the following code: (it is from a table that the representatives have the same code, which generates duplicate values, I solve this by picking the most current representative, in short the last face that synchronized) / em>
select distinct top $numeroRepresentantes
t.nomerepresentante,
t.codigorepresentante
from (SELECT distinct
s.nomeRepresentante,
s.codigorepresentante,
datasinc
FROM vw_Sincronismo s
where s.CodigoRepresentante in(102,120)
ORDER BY s.datasinc desc) as t
That returns me the following error:
Message 1033, Level 15, State 1, Line 5 The ORDER BY clause is invalid in views, built-in functions, derived tables, common subqueries and table expressions, unless TOP, OFFSET, or FOR XML is also specified.
Sorry for the ignorance I do not understand a lot of SQL, but I need all the results of the table to appear, if necessary, I can not use a TOP numerogrande to solve my problems, I would like to understand what happened here