Re: [GENERAL] Selecting pairs of numbers

2015-10-06 Thread Albe Laurenz
Charles Clavadetscher wrote: >> aklaver@test=> create table pr_test(x int, y int); >> >> aklaver@test=> select * from pr_test where (x, y) between (1, 3) and >> (3,2) order by x,y; >> x | y >> ---+--- >> 1 | 3 >> 1 | 4 >> 2 | 1 >> 2 | 2 >> 2 | 3 >> 2 | 4 >> 3 | 1 >> 3 | 2 > > +1

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Charles Clavadetscher
> aklaver@test=> create table pr_test(x int, y int); > > aklaver@test=> select * from pr_test where (x, y) between (1, 3) and > (3,2) order by x,y; > x | y > ---+--- > 1 | 3 > 1 | 4 > 2 | 1 > 2 | 2 > 2 | 3 > 2 | 4 > 3 | 1 > 3 | 2 +1, nice. -- Sent via pgsql-general mailing

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Adrian Klaver
On 10/05/2015 12:33 PM, Raymond O'Donnell wrote: On 05/10/2015 20:08, Adrian Klaver wrote: On 10/05/2015 12:00 PM, Raymond O'Donnell wrote: On 05/10/2015 19:53, Adrian Klaver wrote: On 10/05/2015 11:39 AM, Raymond O'Donnell wrote: Hello all, I have an SQL problem which ought to be simple, bu

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Raymond O'Donnell
On 05/10/2015 20:08, Adrian Klaver wrote: > On 10/05/2015 12:00 PM, Raymond O'Donnell wrote: >> On 05/10/2015 19:53, Adrian Klaver wrote: >>> On 10/05/2015 11:39 AM, Raymond O'Donnell wrote: Hello all, I have an SQL problem which ought to be simple, but I can't get my head aroun

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Raymond O'Donnell
On 05/10/2015 20:03, John McKown wrote: > When in doubt, cheat! Why not something like: > > SELECT x, y FROM organ_pipes WHERE point(x,y) <@ > box(point(?x1,?y1),point(?x2,?y2)) ; > > This is definitely a different approach from the others that I've seen. > > > Basically, think of your channel

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Raymond O'Donnell
On 05/10/2015 19:53, Adrian Klaver wrote: > On 10/05/2015 11:39 AM, Raymond O'Donnell wrote: >> Hello all, >> >> I have an SQL problem which ought to be simple, but I can't get my head >> around it. >> >> I have pairs of integers - let's call them (x, y). In effect, x is a >> category, while y is a

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Adrian Klaver
On 10/05/2015 12:00 PM, Raymond O'Donnell wrote: On 05/10/2015 19:53, Adrian Klaver wrote: On 10/05/2015 11:39 AM, Raymond O'Donnell wrote: Hello all, I have an SQL problem which ought to be simple, but I can't get my head around it. I have pairs of integers - let's call them (x, y). In effec

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread John McKown
When in doubt, cheat! Why not something like: SELECT x, y FROM organ_pipes WHERE point(x,y) <@ box(point(?x1,?y1),point(?x2,?y2)) ; This is definitely a different approach from the others that I've seen. Basically, think of your channel / piston as a point in a Cartesian plane. And your boundar

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Igor Neyman
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Raymond O'Donnell Sent: Monday, October 05, 2015 2:40 PM To: 'PostgreSQL' Subject: [GENERAL] Selecting pairs of numbers Hello all, I have an SQL problem

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Adrian Klaver
On 10/05/2015 11:39 AM, Raymond O'Donnell wrote: Hello all, I have an SQL problem which ought to be simple, but I can't get my head around it. I have pairs of integers - let's call them (x, y). In effect, x is a category, while y is an item within that category. For every x, there is always the

Re: [GENERAL] Selecting pairs of numbers

2015-10-05 Thread Chris Mair
I then might want to extract a list from, say, (1, 3) to (3, 2), giving: x | y - 1 | 3 1 | 4 2 | 1 2 | 2 2 | 3 2 | 4 3 | 1 3 | 2 For the life of me, I can't figure out how to do this. Hi, starting from this: chris=# select * from t order by x,y; x | y ---+--- 1 | 1 1 | 2 1 | 3 1 |

[GENERAL] Selecting pairs of numbers

2015-10-05 Thread Raymond O'Donnell
Hello all, I have an SQL problem which ought to be simple, but I can't get my head around it. I have pairs of integers - let's call them (x, y). In effect, x is a category, while y is an item within that category. For every x, there is always the same number of integers y; and both x and y are al