Hello.
I am not being able to sort the lines in a portlet of the type “HtmlAdvanced”, which is fed by an SQL query (SELECT). I would expect that the lines were shown in the same order that they appear if I execute the “SELECT” in Azure Data Studio and SQL Management Studio, ie, according to the “ORDER BY” clause, but whichever this is, the lines always appear sorted in the same way, not related with the “ORDER BY” clause, and I don’t even figure out what sort key is used.
SELECT TOP 100 PERCENT Id
, [PortalNovacura].[dbo].NotAlertHtm(Texto, Url, imgUrl, imgPosition, imgWidth, imgHeight) as Htm
FROM [PortalNovacura].[dbo].[Noticias]
WHERE tipo=‘ale’ AND TRIM(Texto)<>‘’
AND ISNULL(Enabled,1)<>0 AND (DtExpira is NULL OR DtExpira >= getdate())
ORDER BY Id DESC
[PortalNovacura].[dbo].NotAlertHtm(…) is a SQL function that builds the HTML code shown in each line, using the “configuration data” that is shown in the top table (NOTICIAS BO TABLE), which uses an SQL on the same table. The WHERE clause serves to select only the records that are of the type intended and are enabled.
Note that if the “ORDER BY” was respected the lines on the “ALERTA” table would show with the following order:
- “Acessos à A3 …” (Id=6)
- “Proteção Civil …” (Id=4)
- “Câmara de Lisboa …” (Id=3)
But, as yo can see, it shows first the Id=3, then Id=4 and then Id=6. The same happens when I use the a column that contains de datetime of the last update, either with ASC or DESC, and this sort order is equivalent of SORT BY Id with the current data.
Anyone has any clue on what is the cause of this behavior and what can de done so I can have control over the sort order?
Thank you.
Regards.
Anyone has any clue on what is the cause of this behavior and what can de done so I can have control over the sort order?
Thank you.
Regards.