Re: Sort question - Fractions, Metric etc

From: Pól Ua Laoínecháin <linehanp(at)tcd(dot)ie>
To: Bret Stern <bret_stern(at)machinemanagement(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Sort question - Fractions, Metric etc
Date: 2021-08-15 07:42:26
Message-ID: CAF4RT5SFq2q9H4YUMHs6fzJZ=TFpOEj0h9wYyoCPUusZt7tkng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I have a table with metric, imperial, fraction columns.

Have "metric_equivalent_magnitude" and "metric_equivalent_unit"
columns and do all your sorting &c. via those columns. Use the
relatively new generated (or computed/calculated) columns to calculate
these. That way, you get the conversion correct once and you don't
have to worry about it any more!

That way, you can compare between cubits, furlongs and kilometres or
barrels, hogsheads and litres & American and British imperial units.

You might also want a metric_equivalent_type to ensure that you're not
comparing lengths with volumes, masses or velocities... &c...?

Pól...

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shrikant Bhende 2021-08-15 08:21:40 Re: Join for the parent table will not leverage the index scan
Previous Message Adrian Klaver 2021-08-14 23:25:45 Re: Sort question - Fractions, Metric etc