From: | hamann(dot)w(at)t-online(dot)de |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: sql questions |
Date: | 2018-07-21 04:23:07 |
Message-ID: | wolfgang-1180721062307.A0117279@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>> Zitat von hamann(dot)w(at)t-online(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2018-07-21 06:36:55 | Re: In certain cases, can UPDATE transactions fail rather than block waiting for “FOR UPDATE lock”? |
Previous Message | Joshua D. Drake | 2018-07-21 00:37:35 | Re: User documentation vs Official Docs |