SQL server question

Results 1 to 3 of 3

Thread: SQL server question

  1. #1
    Join Date
    Dec 1969

    Default SQL server question

    HI,<BR> I have a query like this <BR><BR>Select distinct field1 from table1 order by field2 <BR><BR>but SQL server gives an error like <BR><BR>ORDER BY items must appear in the select list if SELECT DISTINCT is specified. <BR><BR>I need to have the query like this . Can some one tell me how to modify the query to make it work.<BR><BR>thank you<BR>Rajesh<BR>

  2. #2
    Join Date
    Dec 1969

    Default Have to do what it says...

    Either<BR><BR>Select distinct field1 from table1 order by field1<BR><BR>or<BR><BR>Select distinct field1, field2 from table1 order by field2<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default or....

    ..if he really does want it in the form he suggests,<BR><BR>Select field1 from table1 group by field1 order by min(field2)<BR><BR>..or some other appropriate aggregrate function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts