0
I have ONE test table and I’m doing a Union All and I want to sort by date but not sort by the first select before Union All which would be a headline. I would like to order only the data of the second select, could you help me? The first select should be fixed to the first row as it is like a description of the column.
SELECT
'NOME_FUNCIONARIO',
'DATA_FUNCIONARIO'
UNION ALL
SELECT NOME
,CONVERT(VARCHAR,DATA,106)
FROM B
ORDER BY 2
So that this header !?
– Motta
If the ORDER BY clause should apply to only one of the SELECT participating in the UNION then use parentheses, otherwise it will apply to the UNION result. In your case put the second SELECT in parentheses.
– anonimo