🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych
Article #195719

Re: Niepowracający klienci

#195719
From: Adam M
Date: Thu, 03 Sep 2020 17:42
32 lines
2412 bytes
On Thursday, September 3, 2020 at 9:34:29 AM UTC-4, Radziwil wrote:
> czwartek, 3 września 2020 o 14:22:43 UTC+2 Radziwil napisał(a): 
> > Hej 
> > 
> > Poszukuję najprostszego rozwiązania, jak wybrać z tabeli np.: 
> > ID, IDKlient, Data 
> > wszystkich klientów, którzy kupili pizze w zadanym przedziale czasu i nie zamówili już nigdy więcej. 
> > 
> > Pozdrawiam 
> > Darek
> Rozwiązanie okazało się prostsze niż przypuszczałem: 
> select t.idklienta 
> from tabela t 
> where t.data between to_date ('2020-01-01', 'YYYY-MM-DD') and to_date ('2020-01-31', 'YYYY-MM-DD') 
> minus 
> select t.idklienta 
> from tabela t 
> where t.data > to_date ('2020-01-31', 'YYYY-MM-DD') 
> 
> i to tyle. Przykład dla bazy Oracle. Nie testowałem na innych bazach danych. 
> 
> Pozdrawiam 
> Darek
Dla PstgreSQL

 select t.idklienta 
 from tabela t 
 where t.data between to_date ('2020-01-01', 'YYYY-MM-DD') and to_date ('2020-01-31', 'YYYY-MM-DD') 
 except
 select t.idklienta 
 from tabela t 
 where t.data > to_date ('2020-01-31', 'YYYY-MM-DD') 
Technical Details
Message-ID: <7fb6b662-8d74-43e4-9fe9-d56f90f54e8en@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!news.samoylyk.net!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
References: <f3f35f53-e86c-4d8e-a9bc-96635cd90515n@googlegroups.com> <79a1d772-f917-46b7-89d6-aa1f4d583e57n@googlegroups.com>

Show Full Headers
Complete Article Headers
X-Received: by 2002:ac8:23a3:: with SMTP id q32mr4677098qtq.361.1599154938215;        Thu, 03 Sep 2020 10:42:18 -0700 (PDT)
X-Received: by 2002:a25:517:: with SMTP id 23mr4077534ybf.116.1599154937786; Thu, 03 Sep 2020 10:42:17 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!news.samoylyk.net!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: pl.comp.bazy-danych
Date: Thu, 3 Sep 2020 10:42:17 -0700 (PDT)
In-Reply-To: <79a1d772-f917-46b7-89d6-aa1f4d583e57n@googlegroups.com>
Complaints-To: groups-abuse@google.com
Injection-Info: google-groups.googlegroups.com; posting-host=50.248.133.1; posting-account=aFGPVQoAAADngh59qlchYygiuB87zBBU
NNTP-Posting-Host: 50.248.133.1
References: <f3f35f53-e86c-4d8e-a9bc-96635cd90515n@googlegroups.com> <79a1d772-f917-46b7-89d6-aa1f4d583e57n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7fb6b662-8d74-43e4-9fe9-d56f90f54e8en@googlegroups.com>
Subject: Re: Niepowracający klienci
From: Adam M <amorawski@magna-power.com>
Injection-Date: Thu, 03 Sep 2020 17:42:18 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit