Home » SQL & PL/SQL » SQL & PL/SQL » Update repeated data
Update repeated data [message #200426] Mon, 30 October 2006 20:52 Go to next message
jung1975
Messages: 5
Registered: October 2006
Location: U.S.A
Junior Member
I have data looks like below
ID                   date         HGB      EPo
9000058     02-SEP-06             35.1     1500     
9000058     05-SEP-06                      1500     
9000058     07-SEP-06                      1500     
9000058     09-SEP-06                      1500     
9000058     12-SEP-06             39.3     1500     
9000058     14-SEP-06             39.3     1500     
9000058     16-SEP-06             39.3     1000     
9000058     19-SEP-06             39.3     1000     
9000058     21-SEP-06             39.3     1000     
9000058     23-SEP-06             39.3     1000     
9000058     26-SEP-06             39.3     1000     
9000058     28-SEP-06             39.3     1000     
9000058     30-SEP-06             39.3     1000     

I would like to update the repeated HGB ( row after row) to null in the same ID. In this case, 39.3

The outpit should look like:
ID                   date         HGB      EPo
9000058     02-SEP-06            35.1     1500     
9000058     05-SEP-06                     1500     
9000058     07-SEP-06                     1500     
9000058     09-SEP-06                     1500     
9000058     12-SEP-06            39.3     1500     
9000058     14-SEP-06                     1500     
9000058     16-SEP-06                     1000     
9000058     19-SEP-06                     1000     
9000058     21-SEP-06                     1000     
9000058     23-SEP-06                     1000     
9000058     26-SEP-06                     1000     

How can I do this using update statment?
Re: Update repeated data [message #200473 is a reply to message #200426] Tue, 31 October 2006 01:20 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Now how on Earth would BREAK help to do this:
OP

I would like to update the repeated HGB ( row after row) to null in the same ID

The following UPDATE statement doesn't necessarily have to be correct, but let me try:
UPDATE TEST t
   SET hgb = NULL
 WHERE datum <> (SELECT   MIN (t1.datum)
                     FROM TEST t1
                    WHERE t1.id = t.id
                      AND t1.hgb = t.hgb
                 GROUP BY t1.hgb)

[Updated on: Tue, 31 October 2006 01:30]

Report message to a moderator

Previous Topic: Format the SQL Result
Next Topic: about pl/sql - help me please...urgent needed
Goto Forum:
  


Current Time: Thu Apr 25 11:13:35 CDT 2024