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 1pGjSn-00034G-O6 for pgsql-general@arkaria.postgresql.org; Sat, 14 Jan 2023 16:33:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pGjSm-0001xd-K2 for pgsql-general@arkaria.postgresql.org; Sat, 14 Jan 2023 16:33:00 +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 1pGjSm-0001xU-9F for pgsql-general@lists.postgresql.org; Sat, 14 Jan 2023 16:33:00 +0000 Received: from mailout07.t-online.de ([194.25.134.83]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGjSk-0007Ak-Qp for pgsql-general@lists.postgresql.org; Sat, 14 Jan 2023 16:32:59 +0000 Received: from fwd85.dcpf.telekom.de (fwd85.aul.t-online.de [10.223.144.111]) by mailout07.t-online.de (Postfix) with SMTP id D175AA6EB for ; Sat, 14 Jan 2023 17:32:56 +0100 (CET) Received: from musicman.homeip.net ([79.252.193.24]) by fwd85.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1pGjSi-1uI3PN0; Sat, 14 Jan 2023 17:32:56 +0100 Received: (qmail 21001 invoked by uid 1000); 14 Jan 2023 16:32:56 -0000 Date: 14 Jan 2023 16:32:56 -0000 Subject: SQL question To: pgsql-general@lists.postgresql.org From: hamann.w@t-online.de Message-Id: X-Mailer: TkMail 4.0beta9 Content-type: text/plain; charset=utf-8 X-TOI-MSGID: 0bf01f80-0332-4871-860a-e4dfe709626f List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, I have atable with a "name" column, and I order it usually order by regexp_match(name, 'regex1'), regexp_match(name, 'regex2') orthe equivalent order by (regexp_match(name, 'regex1'))[1], (regexp_match(name, 'regex2'))[2] Is there a wayto create a function so the statement could read select ... order by myfunc(name) Best regards Wolfgang