pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: hamann.w@t-online.de
To: pgsql-general@lists.postgresql.org
Subject: Re: sql questions
Date: 21 Jul 2018 04:23:07 -0000
Message-ID: <wolfgang-1180721062307.A0117279@localhost> (raw)
In-Reply-To: <20180720150753.817240u65vouisis@www.gelassene-pferde.biz>
>> 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
view thread (5+ messages)
Message-ID: <wolfgang-1180721062307.A0117279@localhost> Permalink: ../wolfgang-1180721062307.A0117279@localhost/ Also on: postgresql.org/message-id/wolfgang-1180721062307.A0117279@localhost ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients from your mail client; the link fills in the headers below: reply via email Some clients, webmail especially, drop In-Reply-To and References from a link, and the reply then starts a new thread: use the mbox below. To: pgsql-general@postgresql.org Cc: hamann.w@t-online.de Subject: Re: sql questions In-Reply-To: <wolfgang-1180721062307.A0117279@localhost> References: <20180720150753.817240u65vouisis@www.gelassene-pferde.biz> <wolfgang-1180721062307.A0117279@localhost> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox