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 1lN1Uk-0006tV-7j for pgsql-general@arkaria.postgresql.org; Thu, 18 Mar 2021 22:51:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lN1Uj-0004aQ-3v for pgsql-general@arkaria.postgresql.org; Thu, 18 Mar 2021 22:51:57 +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 1lN1Ui-0004aJ-SZ for pgsql-general@lists.postgresql.org; Thu, 18 Mar 2021 22:51:56 +0000 Received: from ikarus.unix-solution.de ([31.15.67.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lN1Ug-0005WQ-2N for pgsql-general@lists.postgresql.org; Thu, 18 Mar 2021 22:51:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=unix-solution.de; s=mx; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:To:Subject:MIME-Version:Date:Message-ID:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pdQSaFaePLotN6Pp7diiTIl5rWCpTcuVuD3HfMZXLks=; b=rDFjDFxD1dyF2WasBukxYELnuG nESa1hnN8bhe9H9tFEIDaqQu0J0jyqiecx1l3nKcNyXHyWAI5hEs/neWWSAdrA5ghKHjnzVSo6wSP qHDGFX6+3fYxrFVjpbquIMBIK8OliYbJQThbcRBbul91DaUs/XDefdA7wbxHbKiKHDYs=; Received: from dynamic-078-054-021-043.78.54.pool.telefonica.de ([78.54.21.43] helo=[192.168.30.168]) by ikarus.unix-solution.de with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lN1Ud-0003rr-VL for pgsql-general@lists.postgresql.org; Thu, 18 Mar 2021 23:51:52 +0100 Message-ID: <34c739c1-b930-d58a-521b-c4a7b236d9bd@unix-solution.de> Date: Thu, 18 Mar 2021 23:51:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:86.0) Gecko/20100101 Thunderbird/86.0 Subject: Re: postgresql order lowercase before uppercase To: pgsql-general@lists.postgresql.org References: <5a174fad-c30d-6d65-38c8-a3d9af8377df@unix-solution.de> From: basti In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ACL-Warn: Max 0 failed recipients allowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Am 18.03.21 um 17:19 schrieb Laurenz Albe: > On Thu, 2021-03-18 at 15:39 +0100, basti wrote: >> I need to as follow: >> >> ande >> Amma >> Anit >> Anti >> Brac >> Cali >> .... >> >> I have try ORDER by name COLLATE 'C'; >> >> but this order as follow: >> >> Amma >> Anit >> Anti >> Brac >> Cali >> .... >> ande > > Create an ICU collation: > > CREATE COLLATION inv (PROVIDER = icu, LOCALE = "en-US@CaseFirst=LowerFirst"); > > Then use > > ORDER BY name COLLATE inv > > Yours, > Laurenz Albe > I have try the inv collate, that does not work on PG 9.6 and 10. Order is the same as without collate. SELECT a.name FROM foo as a LEFT JOIN (SELECT name from foo WHERE name = 'lowercase name') as b on a.name = b.name ORDER by b.name,a.name does it. perhaps there is a better way? There is only one name in lowercase and this one must be the first one.