Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Combining single-key sorts to form concatenated-key sort

Combining single-key sorts to form concatenated-key sort

From: Frog2 <FrogRemailer_at_NoReply.Invalid>
Date: 3 Feb 2001 06:51:48 -0000
Message-ID: <NJB1JYZE36925.3276388889@frog.nyarlatheotep.org>

I'm trying to sort some records. Each record consists of three data fields I wish to use as a concatenated key for sorting purposes and some detail fields. All three key fields are alphanumeric. All key fields in every record will always contain a value (no NULLs).

Here's the problem: the language I'm using has a sort function but that function will only let me sort on *one* field of my choice, not all three at once. So how can I achieve a primary - secondary - tertiary sort of these records. Presumably there's some scalable way to sort/merge each lower key with the key above it (or perhaps the reverse, sort from primary key down to lowest-order key).

What I've come with so far is make a list of each key field's unique values

        unique_p , unique_s, unique_t
sorted in the order I want. But then how could I use these to extract the records in correct overall sorted order?

One subtlty - one or more key fields will contain only numbers. So if I try an "strcat-'em all-together" solution I'll get bit by the "10-sorts-after-1-not-2" problem.

Any ideas on how to do this? Please post any replies back to the list so that others may learn.

TIA, Mike Received on Sat Feb 03 2001 - 00:51:48 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US