2 de novembro de 2009

ORDER BY items must appear in the select list if SELECT DISTINCT is specified

This error message appears when you try to execute a SELECT DISTINCT Statement that should be sorted by a column, which does not appear in the SELECT list.

Error:
SELECT DISTINCT Data
FROM Compras
ORDER BY Valor ASC

Solution 1:
SELECT DISTINCT (Data),
Valor
FROM Compras
ORDER BY
Valor ASC

Solution 2:
SELECT DISTINCT (Data)
FROM Compras
ORDER BY Data ASC

Sem comentários:

LinkWithin

Related Posts with Thumbnails