From: Dirk Mika <Dirk.Mika@mikatiming.de>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Help with a selection
Date: Thu, 4 Jul 2019 10:01:02 +0000
Message-ID: <9EB37987-6EB3-4833-9F9A-C255CB432C3F@mikatiming.de> (raw)
In-Reply-To: <785199B14156764C8EB14EF96CEDC44EE0C8EB@xw-exch03.lfv.se>
References: <785199B14156764C8EB14EF96CEDC44EE0C8EB@xw-exch03.lfv.se>
Hi,
I would like to remove an object that doesn’t end ‘00’ and if there are objects that start with the same 4 charcters and ending with 00.
All objects ending with 00 shall remain.
All object not ending with 00 shall remain of there is no object starting with the same 4 characters and ending with 00
What about:
DELETE FROM tab t1
WHERE right (t1.col, 2) != '00'
AND EXISTS
(SELECT 1
FROM tab t2
WHERE t2.col = left (t1.col, 4) || '00');
It deletes rows where the right two characters are not ‘00’ and another row with the same first four characters and ‘00’ at the end exists.
Dirk
--
Dirk Mika
Software Developer
[cid:image001_d0a5cf51-5dd3-4ff5-b428-1016a6d95a0f.png]
mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany
fon +49 2202 2401-1197
dirk.mika@mikatiming.de
www.mikatiming.de
AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika
[cid:CCh2U_f27a5ce6-8556-4db1-8aa4-fd610d6e9efe.jpg]<https://youtu.be/qfOFXrpSKLQ;
Attachments:image001_d0a5cf51-5dd3-4ff5-b428-1016a6d95a0f.png (image/png, 1.7K) downloadview imageCCh2U_f27a5ce6-8556-4db1-8aa4-fd610d6e9efe.jpg (image/jpeg, 107.2K) downloadview image
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: Dirk.Mika@mikatiming.de
Subject: Re: Help with a selection
In-Reply-To: <9EB37987-6EB3-4833-9F9A-C255CB432C3F@mikatiming.de>
References: <785199B14156764C8EB14EF96CEDC44EE0C8EB@xw-exch03.lfv.se> <9EB37987-6EB3-4833-9F9A-C255CB432C3F@mikatiming.de>
* 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