Обсуждение: filter partitions

Поиск
Список
Период
Сортировка

filter partitions

От
Olivier Leprêtre
Дата:

Hi,

 

I wonder how could it be possible to extract partitions that contains a peculiar item

 

Consider 4 partitions 1, 2, 3, 4 with different items A, B, C... inside

 

P item

1 A

1 B

1 C

2 B

2 D

2 G

2 H

3 B

3 C

4 X

4 D

4 Z

 

 

How could a select return partitions 2,4 because they both contains D item ?

 

As a result, I would get :

 

2 B

2 D

2 G

2 H

4 X

4 D

4 Z

 

I can filter partitions with lag, lead, nth_value... but how could I write something like "select P,any (item=D) over (partition by P) from..."

 

Thanks for any help,

 

 


Garanti sans virus. www.avast.com

Re: filter partitions

От
Shreeyansh Dba
Дата:
Hi Oliver,

You can use the below query to get output for filtering table partition 2,4.

select p,item from parent_table where item='D' and p in (2,4) group by p,item;

Hope this helps.



On Tue, Feb 13, 2018 at 8:37 PM, Olivier Leprêtre <o.lepretre@gmail.com> wrote:

Hi,

 

I wonder how could it be possible to extract partitions that contains a peculiar item

 

Consider 4 partitions 1, 2, 3, 4 with different items A, B, C... inside

 

P item

1 A

1 B

1 C

2 B

2 D

2 G

2 H

3 B

3 C

4 X

4 D

4 Z

 

 

How could a select return partitions 2,4 because they both contains D item ?

 

As a result, I would get :

 

2 B

2 D

2 G

2 H

4 X

4 D

4 Z

 

I can filter partitions with lag, lead, nth_value... but how could I write something like "select P,any (item=D) over (partition by P) from..."

 

Thanks for any help,

 

 


Garanti sans virus. www.avast.com

Re: filter partitions

От
Pradeep Kumar
Дата:
select p, max(item) over (partition by p) from item where item='D'

Virus-free. www.avast.com

On Tue, Feb 13, 2018 at 8:37 PM, Olivier Leprêtre <o.lepretre@gmail.com> wrote:

Hi,

 

I wonder how could it be possible to extract partitions that contains a peculiar item

 

Consider 4 partitions 1, 2, 3, 4 with different items A, B, C... inside

 

P item

1 A

1 B

1 C

2 B

2 D

2 G

2 H

3 B

3 C

4 X

4 D

4 Z

 

 

How could a select return partitions 2,4 because they both contains D item ?

 

As a result, I would get :

 

2 B

2 D

2 G

2 H

4 X

4 D

4 Z

 

I can filter partitions with lag, lead, nth_value... but how could I write something like "select P,any (item=D) over (partition by P) from..."

 

Thanks for any help,

 

 


Garanti sans virus. www.avast.com



--
Pradeep

Re: filter partitions

От
pradeep
Дата:
use 


select p, max(item) over (partition by p) from item where item='D'



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-admin-f2076596.html