Skip site navigation (1) Skip section navigation (2)

Sorting Issue

From: "Ozer, Pam" <pozer(at)automotive(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Sorting Issue
Date: 2011-05-09 16:25:16
Message-ID: (view raw or whole thread)
Lists: pgsql-sql
I have the following query

Select  VehicleTrimAbbreviated, VehicleTrimAbbreviatedId

from VehicleTrimAbbreviated

Where vehicleTrimAbbreviated like 'CX%'

order by VehicleTrimAbbreviated asc




532;"CX Hatchback"

536;"CXL Minivan"

3255;"CXL Premium Sedan"

537;"CXL Sedan"

538;"CXL Sport Utility"

3319;"CXL Turbo Sedan"

533;"CX Minivan"

1959;"CX Plus Minivan"

534;"CX Sedan"

535;"CX Sport Utility"

539;"CXS Sedan"


Why would this not sort correctly?  All the CX should be first, then




Here is the table definition:


CREATE TABLE vehicletrimabbreviated


  vehicletrimabbreviatedid integer NOT NULL,

  vehicletrimabbreviated character varying(64),

  vehiclesubmodelid integer,

  vehiclebodystyleid smallint,

  vehiclebodystylegroupid smallint





ALTER TABLE vehicletrimabbreviated OWNER TO app_user;


-- Index: vehicletrimabbreviated_i00


-- DROP INDEX vehicletrimabbreviated_i00;


CREATE UNIQUE INDEX vehicletrimabbreviated_i00

  ON vehicletrimabbreviated

  USING btree



-- Index: vehicletrimabbreviated_i01


-- DROP INDEX vehicletrimabbreviated_i01;


CREATE INDEX vehicletrimabbreviated_i01

  ON vehicletrimabbreviated

  USING btree



-- Index: vehicletrimabbreviated_i02


-- DROP INDEX vehicletrimabbreviated_i02;


CREATE INDEX vehicletrimabbreviated_i02

  ON vehicletrimabbreviated

  USING btree

  (vehiclesubmodelid, vehiclebodystyleid);


-- Index: vehicletrimabbreviated_i03


-- DROP INDEX vehicletrimabbreviated_i03;


CREATE INDEX vehicletrimabbreviated_i03

  ON vehicletrimabbreviated

  USING btree



-- Index: vehicletrimabbreviated_i04


-- DROP INDEX vehicletrimabbreviated_i04;


CREATE INDEX vehicletrimabbreviated_i04

  ON vehicletrimabbreviated

  USING btree

  (vehiclebodystylegroupid, vehiclesubmodelid, vehiclebodystyleid);


-- Index: vehicletrimabbreviated_i05


-- DROP INDEX vehicletrimabbreviated_i05;


CREATE INDEX vehicletrimabbreviated_i05

  ON vehicletrimabbreviated

  USING btree

  (lower(vehicletrimabbreviated::text), vehiclesubmodelid);


-- Index: vehicletrimabbreviated_i06


-- DROP INDEX vehicletrimabbreviated_i06;


CREATE INDEX vehicletrimabbreviated_i06

  ON vehicletrimabbreviated

  USING btree

  (vehiclesubmodelid, vehiclebodystyleid);


Pam Ozer

Data Architect

pozer(at)automotive(dot)com <mailto:pozer(at)automotive(dot)com>  

tel. 949.705.3468



Source Interlink Media

1733 Alton Pkwy Suite 100, Irvine, CA 92606 <>  

Confidentiality Notice- This electronic communication, and all
information herein, including files attached hereto, is private, and is
the property of the sender. This communication is intended only for the
use of the individual or entity named above. If you are not the intended
recipient, you are hereby notified that any disclosure of; dissemination
of; distribution of; copying of; or, taking any action in reliance upon
this communication, is strictly prohibited. If you have received this
communication in error, please immediately notify us by telephone,
(949)-705-3000, and destroy all copies of this communication. Thank you.


pgsql-sql by date

Next:From: Emi LuDate: 2011-05-09 19:37:40
Subject: Re: Sorting Issue
Previous:From: Tarlika Elisabeth SchmitzDate: 2011-05-09 12:17:17
Subject: Trigger: update if record exists

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group