Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?

From: Dave Smith <dave(dot)smith(at)candata(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?
Date: 2003-02-10 19:04:34
Message-ID: 1044903874.12742.28.camel@playpen
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

For this query ..

SELECT DISTINCT t0_s.rec_num FROM sample_request t0_s,
sample_request_line_item t1_li WHERE (t1_li.fulfillment_status =
'Shipped'
AND t1_li.followup_date <= '2003-02-04 20:00:00.000000000+00' AND
(t1_li.customer_prospect_feedback IS NULL OR
t1_li.customer_prospect_feedback = '')) AND
(t0_s.rec_num=t1_li.parentRequest) ORDER BY t0_s.date_of_request DESC

I get this error.

ERROR: For SELECT DISTINCT, ORDER BY expressions must appear in target
list

This seems like a bug. Why do I need date_of_request in the select
section? SQL Spec?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-02-10 19:21:09 Re: renaming table leaves constraint behind [7.3.2]
Previous Message Dave Smith 2003-02-10 18:58:11 Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?