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: 20900
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 Dec 08 12:14:35 CST 2016

Total time taken to generate the page: 0.15402 seconds