pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
sorting by date & time in descending order ??
4+ messages / 4 participants
[nested] [flat]

* sorting by date & time in descending order ??
@ 1999-03-30 13:38  Ralf Weidemann <Finc01@DX1.HRZ.Uni-Dortmund.DE>
  0 siblings, 3 replies; 4+ messages in thread

From: Ralf Weidemann @ 1999-03-30 13:38 UTC (permalink / raw)
  To: PGSQL-GENERAL-ML <pgsql-general@postgresql.org>

Hi all,

I want to sort my output by date & time in descending
order. How can I do this ? Date or time alone is not
enough and the combination of both does not work. At
least in the way I tried it..

Thanks,
Ralf


wdb=> select surname, creationdate, creationtime 
       from message order by creationtime desc;
surname             |creationdate|creationtime
--------------------+------------+------------
Name_1              |  30.03.1999|14:46:17    
Name_2              |  30.03.1999|14:05:47    
Name_2              |  30.03.1999|10:10:04    
Name_2              |  29.03.1999|09:10:04    
Name_2              |  30.03.1999|09:10:04    
Name_3              |  22.03.1999|06:02:55    
(6 rows)

wdb=> select surname, creationdate, creationtime 
       from message order by creationdate desc;
surname             |creationdate|creationtime
--------------------+------------+------------
Name_2              |  30.03.1999|14:05:47    
Name_2              |  30.03.1999|10:10:04    
Name_1              |  30.03.1999|14:46:17    
Name_2              |  30.03.1999|09:10:04    
Name_2              |  29.03.1999|09:10:04    
Name_3              |  22.03.1999|06:02:55    
(6 rows)

wdb=> select surname, creationdate, creationtime 
       from message order by creationdate, creationtime desc;
surname             |creationdate|creationtime
--------------------+------------+------------
Name_3              |  22.03.1999|06:02:55    
Name_2              |  29.03.1999|09:10:04    
Name_1              |  30.03.1999|14:46:17    
Name_2              |  30.03.1999|14:05:47    
Name_2              |  30.03.1999|10:10:04    
Name_2              |  30.03.1999|09:10:04    
(6 rows)


CREATE TABLE  Message
(
	MessageID			SMALLINT	NOT NULL,
    Title				CHAR(20)	NOT NULL,		
    Surname				CHAR(50)	NOT NULL,		
	EMail				CHAR(100),
	MessageURL			CHAR(100),
	Text				VARCHAR		NOT NULL,
	CreationDate		DATE		NOT NULL,
	CreationTime		TIME		NOT NULL,
    Expiry				SMALLINT	NOT NULL		
);




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [GENERAL] sorting by date & time in descending order ??
@ 1999-03-30 14:00  Herouth Maoz <herouth@oumail.openu.ac.il>
  parent: Ralf Weidemann <Finc01@DX1.HRZ.Uni-Dortmund.DE>
  2 siblings, 0 replies; 4+ messages in thread

From: Herouth Maoz @ 1999-03-30 14:00 UTC (permalink / raw)
  To: Ralf Weidemann <RalfW@Scalar.DE>; pgsql-sql

(The topic of this question fits better in the SQL list than the GENERAL list).

At 15:38 +0200 on 30/03/1999, Ralf Weidemann wrote:

> I want to sort my output by date & time in descending
> order. How can I do this ? Date or time alone is not
> enough and the combination of both does not work. At
> least in the way I tried it..
[snip]
>
> wdb=> select surname, creationdate, creationtime
>        from message order by creationdate, creationtime desc;
> surname             |creationdate|creationtime
> --------------------+------------+------------
> Name_3              |  22.03.1999|06:02:55
> Name_2              |  29.03.1999|09:10:04
> Name_1              |  30.03.1999|14:46:17
> Name_2              |  30.03.1999|14:05:47
> Name_2              |  30.03.1999|10:10:04
> Name_2              |  30.03.1999|09:10:04
> (6 rows)

You have to indicate whether you want ascending or descending sort on each
of the sort columns. When you don't, the default is ascending. Thus, the
above statement is equivalent to:

  ... order by creationdate asc, creationtime desc;

So, you need to use

  ... order by creationdate desc, cretaiontime desc;

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [GENERAL] sorting by date & time in descending order ??
@ 1999-03-30 14:49  Kollar Lajos <KOLLARLAJOS@TIGRIS.KLTE.HU>
  parent: Ralf Weidemann <Finc01@DX1.HRZ.Uni-Dortmund.DE>
  2 siblings, 0 replies; 4+ messages in thread

From: Kollar Lajos @ 1999-03-30 14:49 UTC (permalink / raw)
  To: Ralf Weidemann <RalfW@Scalar.DE>; +Cc: PGSQL-GENERAL-ML <pgsql-general@postgreSQL.org>



On Tue, 30 Mar 1999, Ralf Weidemann wrote:

> Hi all,
> 
> I want to sort my output by date & time in descending
> order. How can I do this ? Date or time alone is not
> enough and the combination of both does not work. At
> least in the way I tried it..
> 
> Thanks,
> Ralf
> 
> ...
> 
> wdb=> select surname, creationdate, creationtime 
>        from message order by creationdate, creationtime desc;
> surname             |creationdate|creationtime
> --------------------+------------+------------
> Name_3              |  22.03.1999|06:02:55    
> Name_2              |  29.03.1999|09:10:04    
> Name_1              |  30.03.1999|14:46:17    
> Name_2              |  30.03.1999|14:05:47    
> Name_2              |  30.03.1999|10:10:04    
> Name_2              |  30.03.1999|09:10:04    
> (6 rows)
> 
this orders creationdate asc and creationtime desc as the output also shows,
so try:

select surname, creationdate, creationtime
  from message order by creationdate desc, creationtime desc;

this should work.

			Lajos




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [GENERAL] sorting by date & time in descending order ??
@ 1999-07-06 23:55  Bob Dusek <bobd@palaver.net>
  parent: Ralf Weidemann <Finc01@DX1.HRZ.Uni-Dortmund.DE>
  2 siblings, 0 replies; 4+ messages in thread

From: Bob Dusek @ 1999-07-06 23:55 UTC (permalink / raw)
  To: Ralf Weidemann <RalfW@Scalar.DE>; +Cc: PGSQL-GENERAL-ML <pgsql-general@postgreSQL.org>

Hi Ralph,

Did you try: 

select surname, creationdate, creationtime from message order by
creationdate desc, creationtime desc;

??

It appears that all of your other queries are working as expected.

Bob

Ralf Weidemann wrote:
> 
> Hi all,
> 
> I want to sort my output by date & time in descending
> order. How can I do this ? Date or time alone is not
> enough and the combination of both does not work. At
> least in the way I tried it..
> 
> Thanks,
> Ralf
> 
> wdb=> select surname, creationdate, creationtime
>        from message order by creationtime desc;
> surname             |creationdate|creationtime
> --------------------+------------+------------
> Name_1              |  30.03.1999|14:46:17
> Name_2              |  30.03.1999|14:05:47
> Name_2              |  30.03.1999|10:10:04
> Name_2              |  29.03.1999|09:10:04
> Name_2              |  30.03.1999|09:10:04
> Name_3              |  22.03.1999|06:02:55
> (6 rows)
> 
> wdb=> select surname, creationdate, creationtime
>        from message order by creationdate desc;
> surname             |creationdate|creationtime
> --------------------+------------+------------
> Name_2              |  30.03.1999|14:05:47
> Name_2              |  30.03.1999|10:10:04
> Name_1              |  30.03.1999|14:46:17
> Name_2              |  30.03.1999|09:10:04
> Name_2              |  29.03.1999|09:10:04
> Name_3              |  22.03.1999|06:02:55
> (6 rows)
> 
> wdb=> select surname, creationdate, creationtime
>        from message order by creationdate, creationtime desc;
> surname             |creationdate|creationtime
> --------------------+------------+------------
> Name_3              |  22.03.1999|06:02:55
> Name_2              |  29.03.1999|09:10:04
> Name_1              |  30.03.1999|14:46:17
> Name_2              |  30.03.1999|14:05:47
> Name_2              |  30.03.1999|10:10:04
> Name_2              |  30.03.1999|09:10:04
> (6 rows)
> 
> CREATE TABLE  Message
> (
>         MessageID                       SMALLINT        NOT NULL,
>     Title                               CHAR(20)        NOT NULL,
>     Surname                             CHAR(50)        NOT NULL,
>         EMail                           CHAR(100),
>         MessageURL                      CHAR(100),
>         Text                            VARCHAR         NOT NULL,
>         CreationDate            DATE            NOT NULL,
>         CreationTime            TIME            NOT NULL,
>     Expiry                              SMALLINT        NOT NULL
> );



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-07-06 23:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-03-30 13:38 sorting by date & time in descending order ?? Ralf Weidemann <Finc01@DX1.HRZ.Uni-Dortmund.DE>
1999-03-30 14:00 ` Herouth Maoz <herouth@oumail.openu.ac.il>
1999-03-30 14:49 ` Kollar Lajos <KOLLARLAJOS@TIGRIS.KLTE.HU>
1999-07-06 23:55 ` Bob Dusek <bobd@palaver.net>

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