RE: SQL question

  • From: "Lex de Haan" <lex.de.haan@xxxxxxxxxxxxxx>
  • To: "'Henry Poras'" <henry@xxxxxxxxxxxxxxx>, <jhn.aida@xxxxxx>, <geraldine_2@xxxxxxxxxxx>
  • Date: Fri, 3 Dec 2004 21:29:34 +0100

That's an interesting thought.
Now, the next question becomes: have these lines (pipes, ...) a direction?
A vector from point A to point B is not the same as a vector from point B to
point A...
But if (as apparently in this case) A and B can freely be swapped, because
there is no direction involved,
I guess it makes sense to define some ordering in the column values and
always put the smaller value in A and the larger one in B -- just like we do
in mathematics, and in time interval notations. We never talk about the
interval [42,13] but always about [13,42]. This translates into a relatively
easy row-level constraint: A less than or equal to B.

Obviously, for this to work you need "some ordering" in the column
population.

Cheers,
 
Lex.
 
----------------------------------------------------------------
Tom Kyte Seminar: http://www.naturaljoin.nl/events/seminars.html
----------------------------------------------------------------
 

-----Original Message-----
From: Henry Poras [mailto:henry@xxxxxxxxxxxxxxx] 
Sent: Friday, December 03, 2004 21:04
To: lex.de.haan@xxxxxxxxxxxxxx; jhn.aida@xxxxxx; geraldine_2@xxxxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
Subject: RE: SQL question

How about a line (pipe, HV, ...) with endpoints a and b?

Henry

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Lex de Haan
Sent: Friday, December 03, 2004 12:58 PM
To: jhn.aida@xxxxxx; geraldine_2@xxxxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
Subject: RE: SQL question


Hah -- comments ... Thanks for challenging me, Jesper :-) Well, my first
thought (when I saw this question) was: what are these columns A and B
supposed to mean in real world, to make this type of questions "reasonable"
in the first place? In other words, aren't we looking at a design mistake
here? How can you have two columns that apparently have precisely the same
meaning?

And another question: what is the primary key of this table?

Relational, relational, ... Isn't a table just like a spreadsheet, with rows
and columns? :-)

Undskyld, undskyld,

Lex.
 
----------------------------------------------------------------
Tom Kyte Seminar: http://www.naturaljoin.nl/events/seminars.html
----------------------------------------------------------------
 

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Jesper Haure Norrevang
Sent: Friday, December 03, 2004 18:07
To: geraldine_2@xxxxxxxxxxx
Cc: oracle-l@xxxxxxxxxxxxx
Subject: Re: SQL question

Geraldine,

select a, b
from mytable
where a <= b
union
select b, a
from mytable
where b = a

In Set Theory the set (1, 2) is equal to (2, 1).

Relational databases are (more and less) good implementations of Set Theory.
Basicly you are asking for a Set of Sets. Quite interesting. May be Lex has
some comments on this?

Regards
Jesper Haure


----- Original Message -----
From: geraldine_2@xxxxxxxxxxx
Date: Friday, December 3, 2004 5:37 pm
Subject: SQL question

> Hi,
> I have the following table below
> 
> SQL> select * FRom mytable;
>        A          B
> ---------- ----------
>         1          2
>         3          4
>         2          1
>         5          6
>         4          3
> 
> 5 rows selected.
> 
> and I like to get the following output:
> 
>        A          B
> ---------- ----------
>         1          2
>         3          4
>         5          6
>        
> 
> basically (1,2) is the same as (2,1) and I would just like to display 
> any of those combination just once.
> 
> Not sure how I can write a SQL to extract the data. Can someone help.
> 
> TIA.
> 
> Geraldine
> --
> //www.freelists.org/webpage/oracle-l
> 

--
//www.freelists.org/webpage/oracle-l



--
//www.freelists.org/webpage/oracle-l




--
//www.freelists.org/webpage/oracle-l

Other related posts: