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 1jeIYi-0006FO-Vq for pgsql-general@arkaria.postgresql.org; Thu, 28 May 2020 13:26:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jeIYh-0002iB-8p for pgsql-general@arkaria.postgresql.org; Thu, 28 May 2020 13:26:55 +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 1jeIYh-0002i4-1K for pgsql-general@lists.postgresql.org; Thu, 28 May 2020 13:26:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jeIYa-0001z4-IN for pgsql-general@lists.postgresql.org; Thu, 28 May 2020 13:26:54 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 04SDQgva032486; Thu, 28 May 2020 09:26:42 -0400 From: Tom Lane To: Andreas Joseph Krogh cc: Geoff Winkless , "pgsql-generallists.postgresql.org" Subject: Re: Order by lower(column-alias) doesn't work... In-reply-to: References: Comments: In-reply-to Andreas Joseph Krogh message dated "Thu, 28 May 2020 14:55:55 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6287.1590672402.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 28 May 2020 09:26:42 -0400 Message-ID: <6288.1590672402@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andreas Joseph Krogh writes: > Is there a way to define "sorting-rules" on custom-types so that I can h= ave = > ORDER BY and PG will pick my custom ode= ring? = You'd have to write your own type, which would be a lotta work :-(. A possible partial answer is to define the composite type as firstname citext, lastname citext, other-fields-here and then the regular composite-type comparison rule would give you approximately what you said you wanted ... but only approximately. regards, tom lane