Pam Ozer
Data Architect
tel. 949.705.3468 |
| From | Ozer, Pam |
|---|---|
| Subject | Sorting Issue |
| Date | |
| Msg-id | 216FFB77CBFAEE4B8EE4DF0A939FF1D14F85F1@mail-001.corp.automotive.com Whole thread Raw |
| Responses |
Re: Sorting Issue
|
| List | pgsql-sql |
I have the following query
Select VehicleTrimAbbreviated, VehicleTrimAbbreviatedId
from VehicleTrimAbbreviated
Where vehicleTrimAbbreviated like 'CX%'
order by VehicleTrimAbbreviated asc
Results:
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 CXL, Then CXS
Here is the table definition:
CREATE TABLE vehicletrimabbreviated
(
vehicletrimabbreviatedid integer NOT NULL,
vehicletrimabbreviated character varying(64),
vehiclesubmodelid integer,
vehiclebodystyleid smallint,
vehiclebodystylegroupid smallint
)
WITH (
OIDS=FALSE
);
ALTER TABLE vehicletrimabbreviated OWNER TO app_user;
-- Index: vehicletrimabbreviated_i00
-- DROP INDEX vehicletrimabbreviated_i00;
CREATE UNIQUE INDEX vehicletrimabbreviated_i00
ON vehicletrimabbreviated
USING btree
(vehicletrimabbreviatedid);
-- Index: vehicletrimabbreviated_i01
-- DROP INDEX vehicletrimabbreviated_i01;
CREATE INDEX vehicletrimabbreviated_i01
ON vehicletrimabbreviated
USING btree
(lower(vehicletrimabbreviated::text));
-- 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
(vehiclebodystyleid);
-- 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);
|
| 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.
Соглашаюсь с условиями обработки персональных данных