Selecting records with equal vectors

Selecting records with equal vectors

am 19.03.2007 14:41:25 von weh

Suppose we have a table tab ín which there are fields X, Y, ...
which designate the coordinates of n-dimensional vectors.

We would like to select all records which contain the same vectors

Exapmple n=2

ID X Y
01 1 2
02 1 3
03 1 2
04 2 3

The select statement should yield the records with ID 01 and 03
(vectors (1,2))

There might of course be several sets of equal vector records.

In the end we would like to have a list of all those equal vector
records.

In my practical case n=2 is sufficient but a general formulation would
be interesting as well.

Any help and suggestions would be greatly appreciated.

Wolfgang

Re: Selecting records with equal vectors

am 19.03.2007 15:34:55 von zac.carey

On Mar 19, 1:41 pm, "Dr. Wolfgang Hintze" wrote:
> Suppose we have a table tab =EDn which there are fields X, Y, ...
> which designate the coordinates of n-dimensional vectors.
>
> We would like to select all records which contain the same vectors
>
> Exapmple n=3D2
>
> ID X Y
> 01 1 2
> 02 1 3
> 03 1 2
> 04 2 3
>
> The select statement should yield the records with ID 01 and 03
> (vectors (1,2))
>
> There might of course be several sets of equal vector records.
>
> In the end we would like to have a list of all those equal vector
> records.
>
> In my practical case n=3D2 is sufficient but a general formulation would
> be interesting as well.
>
> Any help and suggestions would be greatly appreciated.
>
> Wolfgang

Sorry, I don't understand the implications of n in this problem...

SELECT DISTINCT (v1.id), v2.x, v2.y
FROM vectors v1
LEFT JOIN vectors v2 ON v1.id <> v2.id
WHERE v1.x =3D v2.x
AND v1.y =3D v2.y
ORDER BY v1.x, v1.y, v1.id
;

Re: Selecting records with equal vectors

am 19.03.2007 15:39:20 von zac.carey

On Mar 19, 2:34 pm, "strawberry" wrote:
> On Mar 19, 1:41 pm, "Dr. Wolfgang Hintze" wrote:
>
>
>
> > Suppose we have a table tab =EDn which there are fields X, Y, ...
> > which designate the coordinates of n-dimensional vectors.
>
> > We would like to select all records which contain the same vectors
>
> > Exapmple n=3D2
>
> > ID X Y
> > 01 1 2
> > 02 1 3
> > 03 1 2
> > 04 2 3
>
> > The select statement should yield the records with ID 01 and 03
> > (vectors (1,2))
>
> > There might of course be several sets of equal vector records.
>
> > In the end we would like to have a list of all those equal vector
> > records.
>
> > In my practical case n=3D2 is sufficient but a general formulation would
> > be interesting as well.
>
> > Any help and suggestions would be greatly appreciated.
>
> > Wolfgang
>
> Sorry, I don't understand the implications of n in this problem...
>
> SELECT DISTINCT (v1.id), v2.x, v2.y
> FROM vectors v1
> LEFT JOIN vectors v2 ON v1.id <> v2.id
> WHERE v1.x =3D v2.x
> AND v1.y =3D v2.y
> ORDER BY v1.x, v1.y, v1.id
> ;

Oh I see - yes just add an AND for each dimension:

WHERE v1.x =3D v2.x
AND v1.y =3D v2.y
AND v1.z =3D v2.z
AND v1.m =3D v2.m
AND v1.n =3D v2.n
AND v1.h =3D v2.h
AND v1.w =3D v2.w
AND v1.d =3D v2.d

Re: Selecting records with equal vectors

am 19.03.2007 16:11:29 von weh

Thank you very much for your quick and helpful answer.

Wolfgang

"strawberry" schrieb im Newsbeitrag
news:1174315160.694758.137940@y66g2000hsf.googlegroups.com.. .
On Mar 19, 2:34 pm, "strawberry" wrote:
> On Mar 19, 1:41 pm, "Dr. Wolfgang Hintze" wrote:
>
>
>
> > Suppose we have a table tab ín which there are fields X, Y, ...
> > which designate the coordinates of n-dimensional vectors.
>
> > We would like to select all records which contain the same vectors
>
> > Exapmple n=2
>
> > ID X Y
> > 01 1 2
> > 02 1 3
> > 03 1 2
> > 04 2 3
>
> > The select statement should yield the records with ID 01 and 03
> > (vectors (1,2))
>
> > There might of course be several sets of equal vector records.
>
> > In the end we would like to have a list of all those equal vector
> > records.
>
> > In my practical case n=2 is sufficient but a general formulation
> > would
> > be interesting as well.
>
> > Any help and suggestions would be greatly appreciated.
>
> > Wolfgang
>
> Sorry, I don't understand the implications of n in this problem...
>
> SELECT DISTINCT (v1.id), v2.x, v2.y
> FROM vectors v1
> LEFT JOIN vectors v2 ON v1.id <> v2.id
> WHERE v1.x = v2.x
> AND v1.y = v2.y
> ORDER BY v1.x, v1.y, v1.id
> ;

Oh I see - yes just add an AND for each dimension:

WHERE v1.x = v2.x
AND v1.y = v2.y
AND v1.z = v2.z
AND v1.m = v2.m
AND v1.n = v2.n
AND v1.h = v2.h
AND v1.w = v2.w
AND v1.d = v2.d