Re: Get the max(value1, value2, value3) from a table

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: emilu(at)encs(dot)concordia(dot)ca
Cc: "Richard Broersma Jr" <rabroersma(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Get the max(value1, value2, value3) from a table
Date: 2008-01-07 22:40:04
Message-ID: dcc563d10801071440x59211129r424238bc0dc5d697@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Jan 7, 2008 4:37 PM, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:
>
> >
> >> select max(col1) from table
> >> union all
> >> select max(col2) from table
> >> union all
> >> select max(col3) from table
> No, this is not what I prefer; it makes complicate query.

Generally speaking when you have to make complicated queries to get
simple answers, then it's likely you have a normalization issue. IF
col1, col2, col3 were all a single column in an external table the
answer would likely fall out a little simpler.

But honestly, that's not a real complex query. PostgreSQL handles far
more complex queries for me everyday with hardly a murmer..

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-01-07 22:43:27 Re: Get the max(value1, value2, value3) from a table
Previous Message Josh Williams 2008-01-07 22:38:57 Re: Get the max(value1, value2, value3) from a table