Re: SQL question

From: Reinhard Kuhn <kuhn_at_cas-ps.com>
Date: 1996/11/15
Message-ID: <56hc68$7gk_at_fred.cas-ps.com>#1/1


In article <Pine.HPP.3.95.961112161231.4759A-100000_at_penguin.creighton.edu>, pfinn_at_creighton.edu says...
>
>
>Okay, I would really like help on this one. I tried using rowid's but
>that didn't seem to work.
>
>Here's an example of what I'm doing. I'm trying to pull an update off to
>modify one _and_only_one_ occurrence of another field. Like this...
>
> DATE AMOUNT
> ---- ------
> 11/12/96
> 11/12/96
> 11/12/96
> 11/12/96
>
>Now using a regular update scheme, all amounts will be updated wherever a
>a date of 11/12/96 is found. How can I pull it off so that it will only
>update one of those records (I don't care which one, really). Again, I
>tried using rowid, but perhaps my syntax wasn't correct.
>
>Appreciate it.
>

Try :


update
 <table> A
set
  ...
where
 ( date = '11/12/96' ) and
   not exists ( select null from <table> B

                where
                 ( B.date  = A.date  ) and
                 ( B.rowid > A.rowid )
            )

 )

update
 <table> A
set
  ...
where

   rowid = ( select min( rowid )

             from <table> B
             where
             B.date  = '11/12/96'
           )

-----------------------------------------------

hth

-- 
    _/_/_/   _/_/_/ _/    _/  // Reinhard Kuhn             /  It can be      
   _/    _/ _/     _/  _/    //         (kuhn_at_cas-ps.com) /  done quickly,   
  _/_/_/   _/_/_/ _/_/      // CAS GmbH                  /  cheaply or well  
 _/  _/   _/     _/  _/    // Lemberger Strasse 14      /   - pick any two!  
_/   _/  _/_/_/ _/    _/  // 66955 Pirmasens, Germany  /   
                                   
Received on Fri Nov 15 1996 - 00:00:00 CET

Original text of this message