pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Terry Lee Tucker <terry@esc1.com>
To: pgsql-sql@postgresql.org
Subject: Novice SQL Question
Date: Mon, 2 Feb 2004 17:38:06 -0500
Message-ID: <200402021738.06828.terry@esc1.com> (raw)

I need to the following query:
select distinct event_code, level from logs join stat on (stat.prime is not 
null) where order_num = 130680;

Ok, no problem. Does exactly what I want; however, I need to sort this is a 
particular way to get the right results. When I try to add the order by 
clause, I get an error. Here is the ORDER BY:
ORDER BY event_date DESC, event_time DESC, event_secs DESC

If I put this where I thought it should go as in:
select distinct event_code,level from logs join stat on (stat.prime is not 
null) where order_num = 130680 order by event_date,event_time,event_secs;

I get the following error:
ERROR:  For SELECT DISTINCT, ORDER BY expressions must appear in target list

No matter where I put it I get errors. Obviously, I'm a novice. Can somebody 
give me any advice? I'm using Postgres 7.2.3 on RedHat.

Thanks...
-- 
 Work: 1-336-372-6812
 Cell: 1-336-363-4719
email: terry@esc1.com



view thread (3+ messages)  latest in thread

Message-ID: <200402021738.06828.terry@esc1.com>
Permalink:  ../200402021738.06828.terry@esc1.com/
Also on:    postgresql.org/message-id/200402021738.06828.terry@esc1.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: terry@esc1.com
  Subject: Re: Novice SQL Question
  In-Reply-To: <200402021738.06828.terry@esc1.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox