Hi,
I have this query, and I need to order by all by a field except a particular text.
this is the query, I qhant to order all by "CLINOME", but not include in the order the text 'Mostrar Tudo'.
SELECT NULL AS USRLOGIN, NULL AS CLICOD, 'Mostrar Tudo' AS CLINOME
UNION ALL
SELECT CLIENTES.USRLOGIN,CLIENTES.CLICOD, CLIENTES.CLINOME
FROM CLIENTES
INNER JOIN VISITAS
ON CLIENTES.CLICOD=VISITAS.CLICOD
WHERE CLIENTES.CLIACT = 1
AND CLIENTES.USRLOGIN = (CASE WHEN @pUSRLOGIN IS NULL THEN CLIENTES.USRLOGIN ELSE @pUSRLOGIN END)
AND CLIENTES.TIPCOD = (CASE WHEN @pTIPCOD IS NULL THEN CLIENTES.TIPCOD ELSE @pTIPCOD END)
ORDER BY CLINOME
Thanks
I have this query, and I need to order by all by a field except a particular text.
this is the query, I qhant to order all by "CLINOME", but not include in the order the text 'Mostrar Tudo'.
SELECT NULL AS USRLOGIN, NULL AS CLICOD, 'Mostrar Tudo' AS CLINOME
UNION ALL
SELECT CLIENTES.USRLOGIN,CLIENTES.CLICOD, CLIENTES.CLINOME
FROM CLIENTES
INNER JOIN VISITAS
ON CLIENTES.CLICOD=VISITAS.CLICOD
WHERE CLIENTES.CLIACT = 1
AND CLIENTES.USRLOGIN = (CASE WHEN @pUSRLOGIN IS NULL THEN CLIENTES.USRLOGIN ELSE @pUSRLOGIN END)
AND CLIENTES.TIPCOD = (CASE WHEN @pTIPCOD IS NULL THEN CLIENTES.TIPCOD ELSE @pTIPCOD END)
ORDER BY CLINOME
Thanks