From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to select unique records in PostgreSQL
Date: Fri, 25 Nov 2022 08:50:08 -0600
Message-ID: <d39ad33d-1a2e-3cd0-c9c3-c9caabdd0698@gmail.com> (raw)
In-Reply-To: <CAJWX+ENP=04KZ-bHrNpwkqZL0iFuMkDdXnKK4cs0kZNJVnpM4w@mail.gmail.com>
References: <CAJWX+ENP=04KZ-bHrNpwkqZL0iFuMkDdXnKK4cs0kZNJVnpM4w@mail.gmail.com>
Honestly, you do it *in PostgreSQL* the same way you do it in all the other
SQL RDBMSs.
On 11/24/22 06:01, Rama Krishnan wrote:
>
> Hi All,
>
>
> 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
>
>
> create table student_id
> (
> student_wallet_id int,
> card_id int,
> created_date date
> )
>
> insert into student_id values ('w1', 'c1', '2022-04-01')
>
>
> insert into student_id values ('w1', 'c2', '2022-04-03')
>
>
> insert into student_id values ('w1', 'c3', '2022-04-04')
>
> insert into student_id values ('w1', 'c4', '2022-05-01')
> insert into student_id values ('w2', 'c1', '2022-05-01')
> insert into student_id values ('w2', 'c2', '2022-05-04')
> insert into student_id values ('w3', 'c4', '2022-05-05')
> insert into student_id values ('w3', 'c6', '2022-06-03)
> insert into student_id values ('w3', 'c7', '2022-06-05')
> insert into student_id values ('w3', 'c8', '2022-06-07')
> expected output:
> -------------------
>
> months count_wallet_id
> 2022-04 1
> 2022-05 2
> 2022-05 0
>
>
> Regards
>
> A.Rama Krishnan
--
Angular momentum makes the world go 'round.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: ronljohnsonjr@gmail.com
Subject: Re: How to select unique records in PostgreSQL
In-Reply-To: <d39ad33d-1a2e-3cd0-c9c3-c9caabdd0698@gmail.com>
References: <CAJWX+ENP=04KZ-bHrNpwkqZL0iFuMkDdXnKK4cs0kZNJVnpM4w@mail.gmail.com> <d39ad33d-1a2e-3cd0-c9c3-c9caabdd0698@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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