Re: distinct on extract returns composite type

From: Félix GERZAGUET <felix(dot)gerzaguet(at)gmail(dot)com>
To: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: distinct on extract returns composite type
Date: 2019-09-29 10:34:30
Message-ID: CANVwZtuzT1w0aVQMyBi+U=d7e_HQmB70THnqZoxu=xooVRvhbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hello,

On Sun, Sep 29, 2019 at 11:46 AM Mariel Cherkassky <
mariel(dot)cherkassky(at)gmail(dot)com> wrote:

> I'm keep getting composite type (row) instead of two columns. Is there any
> sql way to convert the row type into two columns ? I want to get the first
> and last dates of each quarter with those columns and with this composite
> type I failed doing it
>

This seems to work as you expect:

select distinct extract(year from end_time) as year, extract(quarter from
end_time) quarter from generate_series
( '2017-09-01'::timestamp
, '2019-04-01'::timestamp
, '3 month'::interval) end_time
;

https://www.postgresql.org/docs/current/sql-select.html#SQL-DISTINCT

--

Félix

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2019-09-29 15:32:23 Re: sequence depends on many tables
Previous Message Mariel Cherkassky 2019-09-29 09:46:31 distinct on extract returns composite type