On Fri, 2021-03-19 at 10:12 +0100, basti wrote:
> >> 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?
> >
> > Ah, I misunderstood what you want.
> >
> > SELECT a.name
> > FROM foo as a
> > ORDER BY a.name <> lower(a.name), a.name;
> >
> > That works because FALSE < TRUE.
>
> This does not work for me. The same result as normal order.
>
> Amm
> andere Marken
> Ani
> Anti
> Bra
> Cali
You are allowed to adapt the query to your special needs.
But if you need to be spoonfed:
SELECT a.name
FROM foo as a
ORDER BY a.name = initcap(a.name), a.name;
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com