Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Question
On 21 Dec 2004 11:47:49 -0800, "Bill Mill" <bill.mill_at_gmail.com>
wrote:
>The result I want looks like:
>
>obj_id type site_id
>1 A 101
>2 C 102
>3 B 101
>4 B 101
>5 B 102
>6 A 103
>7 A 103
>
>Do I need to use PL/SQL to achieve this?
You would, unless you redesign your tables. Your problem is not so
much lack of SQL knowledge, but you are also lacking on fundamentals
of relational databases. Relational databases are about sets. A set,
as a mathematic concept, does not have any order.
Consequently B 101 doesn't come 'after' A 101, and you are assuming
there is a specific order which in reality doesn't exist at all, or
won't exist anymore once you start inserting and updating records.
Your thinking is clearly 3GL-oriented.
So your's the choice:
either you rectify your design, by adding an ordering number to your
table, or
you start hacking yourself out with PL/SQL
-- Sybrand Bakker, Senior Oracle DBAReceived on Tue Dec 21 2004 - 14:00:15 CST
![]() |
![]() |