Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: data query question

Re: data query question

From: <MTPConsulting_at_aol.com>
Date: Thu, 18 Jan 2001 14:11:16 EST
Message-Id: <10745.127049@fatcity.com>


Try:

select to_char(trunc(question_date),'DD-MON-YYYY') from student_profile  where student_id = 10
group by trunc(question_date)
order by trunc(question_date);

The distinct keyword outside the to_char was causing Oracle to sort by the character format of the question_date in order to remove duplicates and was overriding your order by clause. The "group by trunc(question_date)" is logically the same as the distinct clause. The trunc is needed to remove the time component of the date. If all of the dates have zeros already, you can remove the trunc function.

Marc Perkowitz
MTP Systems Consulting

In a message dated 1/18/2001 12:54:18 PM Central Standard Time, crivera_at_utep.edu writes:

<< Hello everyone:
 I have a question about a query dealing with dates.  This is my origina query:
 select distinct to_char(question_date,'DD-MON-YYYY') from student_profile  where student_id = 10;
 I get the following results:  

 04-JAN-2001
 05-JAN-2001
 07-NOV-2000
 08-NOV-2000
 09-JAN-2001
 14-NOV-2000
 15-DEC-2000
 15-NOV-2000
 18-JAN-2001
 19-DEC-2000
 20-DEC-2000
 21-DEC-2001
 
 

 I am getting the correct results, but not in the order I expected  (chronological order). I have tried "order by question_date' but no success.    

 Thanks in advance!

 --------------Claudia V. Casas----------------- >>
Received on Thu Jan 18 2001 - 13:11:16 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US