Re: sql questions - Mailing list pgsql-general

From hamann.w@t-online.de
Subject Re: sql questions
Date
Msg-id wolfgang-1180721062307.A0117279@localhost
Whole thread Raw
In response to Re: sql questions  (Thiemo Kellner <thiemo@gelassene-pferde.biz>)
List pgsql-general

>> Zitat von hamann.w@t-online.de:
>> 
>> > a) I am running some select query
>> > select ... order by ....
>> > Now, I would like to preserver the ordering through further  
>> > processing by adding a sequence number
>> > Of course I can do:
>> > create temp sequence mseq;
>> > select xx.*, nextval('mseq') as ord from (select ... order by ....) xx;
>> > drop sequence mseq;
>> > Is there a simpler way (avoiding the create/drop parts)
>> 
>> Can't you just do the ordering at the end of the processing? Maybe you  
>> need to drag along the order by columns and just dump them at the very  
>> end if applicable.
>> 


Hi,

in this specific case every search result consists of a pair of related entries  that are not close to each other in
ordering. So I order by first entry and use the row number to keep the second entry next to the first one,

BTW: the use case is scanning a database of people for duplicates. Whenever there are 3 or more
components in a name, the split betwwen first and last name can be ambiguous, and so its is common to find
both "Ludwig" "van Beethoven" and "Ludwig van" "Beethoven"

Best regards
WOlfgang




pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: User documentation vs Official Docs
Next
From: Alvaro Herrera
Date:
Subject: Re: In certain cases, can UPDATE transactions fail rather than block waiting for “FOR UPDATE lock”?