Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3975452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:41:13+00:00 2026-05-20T04:41:13+00:00

I have a PostgreSQL 8.4 database that is created with the da_DK.utf8 locale. dbname=>

  • 0

I have a PostgreSQL 8.4 database that is created with the da_DK.utf8 locale.

dbname=> show lc_collate;
 lc_collate
------------
 da_DK.utf8
(1 row)

When I select something from a table where I order on a character varying column I get a strange behaviour IMO. When ordering the result PostgreSQL ignores dashes that prefixes the value, e.g.:

 select name from mytable order by name asc;

May return something like

 name
 ----------------
 Ad...
 Ae...
 Ag...
 - Ak....
 At....

The dash prefix seems to be ignored.

I can fix this issue by converting the column to latin1 when ordering:

 select name from mytable order by convert_to(name, 'latin1') asc;

The I get the expected result as:

 name
 ----------------
 - Ak....
 Ad...
 Ae...
 Ag...
 At....

Why does the dash prefix get ignored by default? Can that behavior be changed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:41:13+00:00Added an answer on May 20, 2026 at 4:41 am

    A workaround that will work in my specific case is to replace dashes with exclamation points. I happen to know that I will never get exclamation points and it will be sorted before any letters or digits.

    select name from mytable order by translate(name, '-', '!') asc
    

    It will certainly affect performance so I may look into creating a special column for sorting but I really don’t like that either…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have to get a movie from a PostgreSQL database that matches a given
Is it possible for me to export a database that i have created from
I've got two PostgreSQL databases that have been created using the same sql file.
Background: I have a PostgreSQL (v8.3) database that is heavily optimized for OLTP. I
I have a client that has a PostgreSQL database and he cannot remember the
I currently have an MS Access application that connects to a PostgreSQL database via
I have a database of records that I want to select the most recent
I have created a PostgreSQL database dump using psql . Now I want to
I have a MySQL 5 database that is updated every 5 minutes from a
I created a database in PostgreSQL with encoding = 'UTF8', and loaded some UTF8

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.