Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEwPg-000404-GB for pgsql-general@arkaria.postgresql.org; Sat, 14 Aug 2021 16:21:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mEwPf-0001iB-FF for pgsql-general@arkaria.postgresql.org; Sat, 14 Aug 2021 16:21:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEwPd-0001i3-UF for pgsql-general@lists.postgresql.org; Sat, 14 Aug 2021 16:21:35 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEwPX-0004DN-W9 for pgsql-general@lists.postgresql.org; Sat, 14 Aug 2021 16:21:33 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 4EA303200437; Sat, 14 Aug 2021 12:21:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 14 Aug 2021 12:21:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=u klHL0OprLZPmeFNfUWfIzoG2qnVCc2F4BAIRWKFXBI=; b=kEDja/Y/g+aSEqLi1 EL3k9v7p2eE90N4Jx/vSeZVslN44js4vKjNC5ZcSJp3VEB5j7YcRMQP1j8M5DJe1 pL2iA+NrQ9l3bSbGDpPgSzhGUhFyYwguL5xUYshaTm/vIEHfgEb0nmE1luTGe+AM kOO0PKN+qFBD84SBqF4YM5NhRfrYvDAZFbTyn1kohYM0wbLku5RYZ/nR8mHHF/Hw V/J3ksSDb3nJo5/bbClZLbnAhlwxg0EbioXYMGscgH7+2ookVrWPC4mpBLMyeHUW cssh7rFC4kp5QAQR/oZ+fTHqrGiKwp+DbQxJfbvXVZAstMSnB6BL1xWHTsgU1p8h QsTYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=uklHL0OprLZPmeFNfUWfIzoG2qnVCc2F4BAIRWKFX BI=; b=qxbqHvmPuthA5F7558Eo32V4o4XLdd909P/8H9hGy4MlAEq6wE6YrSWF1 oOZqwEe2BvAS4pqCAOFTMgvBl/brvaZZeX0duGTZalb90kKGpAmS4tDq/x+oKEt3 nrprapieAAHc98Ta7rGwaS17bVbdLVOJHW1m0W7sFqCmLn0kegkTxMw2w8OhEDuo yHKuaGbM6QGnSfssxsfjy+fQR4E+GLwHuqW705yQmvtbMQPKNhxdPmAg30CUKjo1 /IpSzCMiZYPSX9ABp3uI465EvgvXUPsur0qfl5qhHpxIzbdySLHm4ZfXOwvTy+Gm VXN6BR+vORBtU9PuOJvrOtdwTfp8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkeejgddutdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeetjedvteffjeeuvdelieeffeehuedthffgvdfhhffh kedvudevgedvjedufefgveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 14 Aug 2021 12:21:22 -0400 (EDT) Subject: Re: Sort question - Fractions, Metric etc To: Bret Stern , pgsql-general@lists.postgresql.org References: <57f60e61-114f-c403-b2e2-820e76f08d64@machinemanagement.com> From: Adrian Klaver Message-ID: <24d005b3-47a4-3f78-450e-d394b9e47d6f@aklaver.com> Date: Sat, 14 Aug 2021 09:21:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <57f60e61-114f-c403-b2e2-820e76f08d64@machinemanagement.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/14/21 9:14 AM, Bret Stern wrote: > I have a table with metric, imperial, fraction columns. > > Is there a way to sort correctly using imperial (eg; .125, .375, .437 -> > 1., 1.125) Alright how is this different from metric or fraction? I can sort of see fraction if you mean as 1/3, 1/20, etc. What is the data type of the field you are storing this in? > > Couldn't handle it with ORDER BY ASC, DESC args so I added a sort_column > and sorted based > > on those values eg; 1,2,3,4,5,6 indicating the value I need to show in > which sequence. > > > Just curious what the pro's do > > Bret > > > -- Adrian Klaver adrian.klaver@aklaver.com