English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

When I gave it in my querry the following error msg displayed
Server: Msg 145, Level 15, State 1, Line 5
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

2006-09-11 08:12:28 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

this one I'm sure of...

those columns you've specified on the ORDER BY clause must also appear on your DISTINCT clause...

This is wrong:
SELECT DISTINCT column1 FROM table1 ORDER BY column2

This is correct:
SELECT DISTINCT column1,column2 FROM table1 ORDER BY column2

2006-09-11 17:57:59 · answer #1 · answered by muoreh 2 · 0 0

It just sounds like you need to add a sort so that the db knows which row to pick as the "distinct"

Can you give us a copy of the query (fake the fields requested if you prefer) and let us know what flavor of SQL you are using (MySQL, Oracle, MSSQL, etc.)

You can also IM me if you need.

2006-09-11 16:03:46 · answer #2 · answered by John J 6 · 0 0

fedest.com, questions and answers