Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: I need help with an SQL Update query...
Joe wrote:
> Hi,
>
> Lets say that I had a table called TABLEA with 2 columns called ID and
> MY_VALUES as shown in the sample below.
>
> ID MY_VALUES
> == =========
> AA 100
> AA 100
> AA 100
> AA 100
> AA 100
> BB 222
> BB 222
> BB 222
> BB 222
> CC 999
> CC 999
> CC 999
> DD 100
> DD 100
> DD 100
>
> Is there a simple SQL update command that I can use to have the output
> look like this below? Basically,I want to keep the first value of
> MY_VALUES, and zero out the rest for that ID.
>
> ID MY_VALUES
> == =========
> AA 100
> AA 0
> AA 0
> AA 0
> AA 0
> BB 222
> BB 0
> BB 0
> BB 0
> CC 999
> CC 0
> CC 0
> DD 100
> DD 0
> DD 0
>
> Thanks,
> Stumped
What do you mean by "simple"?
If this is homework from a class you need to puzzle this out for yourself. But here is a hint. You want to update one row less than the count of rows of each unique value in your first column.
Daniel Morgan Received on Wed Oct 09 2002 - 15:44:25 CDT
![]() |
![]() |