Re: How to select unique records in PostgreSQL

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How to select unique records in PostgreSQL
Date: 2022-11-25 15:05:33
Message-ID: CAKFQuwbMD+8FvEAx5HUnVS61Sg2YwqhK294G4Pv-7ojKT5Fyig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Nov 25, 2022 at 7:50 AM Ron <ronljohnsonjr(at)gmail(dot)com> wrote:

> Honestly, you do it *in PostgreSQL* the same way you do it in all the
> other SQL RDBMSs.
>

Emphasizing "in PostgreSQL" is nonsensical - it isn't like the OP specified
that they know how to do it in some other RDBMS and are trying to convert
their knowledge to PostgreSQL.

> On 11/24/22 06:01, Rama Krishnan wrote:
>
>
>
> I want to get the unique wallet_id from this table even it was repeated on
> multiple occasions I should calculate only once as well as if the wallet_id
> was calculated on previous month it shouldn't be calculate on next months
>
>
You need a subquery to compute the month in which each wallet_id should
appear (group by wallet_id with min(date) probably), then you can group on
the min(date) column and count the wallets.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2022-11-25 15:28:26 Re: Configure my pgadmin
Previous Message Ted Toth 2022-11-25 15:03:28 Re: table inheritance partition and indexes