Hi,
Order by question_date should definetly work.
Look at my example.
select distinct to_char(question_date,'DD-MON-YYYY')
from student_profile
where student_id = 10
order by question_date;
Example :
SQL> select * from vrr;
W_SLNO W_DATE
---------- ---------------
1 19-dec-00 21:16
2 19-nov-00 21:16
3 20-oct-00 21:16
4 20-sep-00 21:16
SQL> l
1 select to_char(w_date,'dd/mm/yy')
2 from vrr
3* order by w_date
/
TO_CHAR(W_DATE,'DD/MM/YY')
20/09/00
20/10/00
19/11/00
19/12/00
Regards
Rajagopal Venkataramany
- Stephane Faroult <sfaroult_at_oriole.com> wrote:
> "Rivera, Claudia" wrote:
>
> > 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-----------------
> >
> > --
> > Please see the official ORACLE-L FAQ:
> http://www.orafaq.com
> > --
> > Author: Rivera, Claudia
> > INET: crivera_at_utep.edu
> >
> > Fat City Network Services -- (858) 538-5051
> FAX: (858) 538-5051
> > San Diego, California -- Public Internet
> access / Mailing Lists
> >
>
> > To REMOVE yourself from this mailing list, send an
> E-Mail message
> > to: ListGuru_at_fatcity.com (note EXACT spelling of
> 'ListGuru') and in
> > the message BODY, include a line containing: UNSUB
> ORACLE-L
> > (or the name of mailing list you want to be
> removed from). You may
> > also send the HELP command for other information
> (like subscribing).
>
> Claudia,
>
> You have two ways to do it.
> Either you add 'distinct question_date' to your
> list of columns (select list),
> order by it and specify
>
> column question_date noprint
>
> at the SQL*Plus level.
>
> Or you specify the date format beforehand
> alter session set nls_date_format ...
>
> which makes the 'to_char' unecessary and allow you
> to sort on what remains a
> date, i.e. in chronological order.
>
> Regards,
>
> Stephane Faroult
> Oriole Corporation
>
>
> --
> Please see the official ORACLE-L FAQ:
> http://www.orafaq.com
> --
> Author: Stephane Faroult
> INET: sfaroult_at_oriole.com
>
> Fat City Network Services -- (858) 538-5051 FAX:
> (858) 538-5051
> San Diego, California -- Public Internet
> access / Mailing Lists
>
> To REMOVE yourself from this mailing list, send an
> E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of
> 'ListGuru') and in
> the message BODY, include a line containing: UNSUB
> ORACLE-L
> (or the name of mailing list you want to be removed
> from). You may
> also send the HELP command for other information
> (like subscribing).
Received on Thu Jan 18 2001 - 21:24:25 CST