pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Greatest of a list of columns?
3+ messages / 2 participants
[nested] [flat]

* Greatest of a list of columns?
@ 2021-07-01 13:26  Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Ron @ 2021-07-01 13:26 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Postgresql 12.5


What's the canonical Postgresql method for doing, for example, this?
SELECT relname, MAXOF(last_vacuum, last_autovacuum)
FROM pg_stat_user_tables;

Seeing both last_vacuum and last_autovacuum is useful, of course, but 
sometimes I only want to see the "really" last time it was vacuumed.

I can hard code a case statement, but a generic multi-column solution is 
preferred.

Thanks

-- 
Angular momentum makes the world go 'round.





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

* Re: Greatest of a list of columns?
@ 2021-07-01 13:27  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Pavel Stehule @ 2021-07-01 13:27 UTC (permalink / raw)
  To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

čt 1. 7. 2021 v 15:26 odesílatel Ron <ronljohnsonjr@gmail.com> napsal:

> Postgresql 12.5
>
>
> What's the canonical Postgresql method for doing, for example, this?
> SELECT relname, MAXOF(last_vacuum, last_autovacuum)
> FROM pg_stat_user_tables;
>
> Seeing both last_vacuum and last_autovacuum is useful, of course, but
> sometimes I only want to see the "really" last time it was vacuumed.
>
> I can hard code a case statement, but a generic multi-column solution is
> preferred.
>

 postgres=# select greatest(current_date, current_date + 1);
┌────────────┐
│  greatest  │
╞════════════╡
│ 2021-07-02 │
└────────────┘
(1 row)

Pavel



> Thanks
>
> --
> Angular momentum makes the world go 'round.
>
>
>

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

* Re: Greatest of a list of columns?
@ 2021-07-01 13:28  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Pavel Stehule @ 2021-07-01 13:28 UTC (permalink / raw)
  To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>

čt 1. 7. 2021 v 15:27 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:

>
>
> čt 1. 7. 2021 v 15:26 odesílatel Ron <ronljohnsonjr@gmail.com> napsal:
>
>> Postgresql 12.5
>>
>>
>> What's the canonical Postgresql method for doing, for example, this?
>> SELECT relname, MAXOF(last_vacuum, last_autovacuum)
>> FROM pg_stat_user_tables;
>>
>> Seeing both last_vacuum and last_autovacuum is useful, of course, but
>> sometimes I only want to see the "really" last time it was vacuumed.
>>
>> I can hard code a case statement, but a generic multi-column solution is
>> preferred.
>>
>
>  postgres=# select greatest(current_date, current_date + 1);
> ┌────────────┐
> │  greatest  │
> ╞════════════╡
> │ 2021-07-02 │
> └────────────┘
> (1 row)
>
>
https://www.postgresql.org/docs/current/functions-conditional.html


> Pavel
>
>
>
>> Thanks
>>
>> --
>> Angular momentum makes the world go 'round.
>>
>>
>>

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


end of thread, other threads:[~2021-07-01 13:28 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 13:26 Greatest of a list of columns? Ron <ronljohnsonjr@gmail.com>
2021-07-01 13:27 ` Pavel Stehule <pavel.stehule@gmail.com>
2021-07-01 13:28   ` Pavel Stehule <pavel.stehule@gmail.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