pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeddistinct date problem
2+ messages / 2 participants
[nested] [flat]
* distinct date problem
@ 2001-02-25 21:02 Lotus118 <lotus118@excite.com>
2001-02-26 15:05 ` Re: distinct date problem Michael Fork <mfork@toledolink.com>
0 siblings, 1 reply; 2+ messages in thread
From: lotus118@excite.com @ 2001-02-25 21:02 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'm having difficulty figuring this one out:
I have a table with record entries which all have a date attribute, looking
something like '2000-11-11'. What I want from my data base is a list of
all the years that are present in this attribute in the relation. So for
example, if I had a couple of records like:
2000-11-05
1988-02-09
1999-10-06
2001-08-08
1999-09-27
2001-04-04
I would want the query to return:
2000-11-05
1988-02-09
1999-10-06
2001-08-08
So that I get only the distict years.
How does one go about this?
Thanks,
Lotus
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: distinct date problem
2001-02-25 21:02 distinct date problem Lotus118 <lotus118@excite.com>
@ 2001-02-26 15:05 ` Michael Fork <mfork@toledolink.com>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Fork @ 2001-02-26 15:05 UTC (permalink / raw)
To: Lotus118 <lotus118@excite.com>; +Cc: pgsql-sql
This should work:
SELECT distinct(date_part('year', <date field>)) FROM <<date table>>;
Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio
On Sun, 25 Feb 2001, Lotus118 wrote:
> Hi,
> I'm having difficulty figuring this one out:
> I have a table with record entries which all have a date attribute, looking
> something like '2000-11-11'. What I want from my data base is a list of
> all the years that are present in this attribute in the relation. So for
> example, if I had a couple of records like:
> 2000-11-05
> 1988-02-09
> 1999-10-06
> 2001-08-08
> 1999-09-27
> 2001-04-04
> I would want the query to return:
> 2000-11-05
> 1988-02-09
> 1999-10-06
> 2001-08-08
> So that I get only the distict years.
> How does one go about this?
> Thanks,
> Lotus
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-02-26 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-02-25 21:02 distinct date problem Lotus118 <lotus118@excite.com>
2001-02-26 15:05 ` Michael Fork <mfork@toledolink.com>
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