0

I'll clarify this: I have a data result with the twist that the two PK's (A and B) are the same, and field C doesn't.

Example:

A B C D
> 14 20 1 null
> 14 20 2 1
> 15 20 2 0

As you can see, D field has a null and a 0.

What I have to do is to change D's null value to 1 whenever A fields are the same, and there's more than 1 record with those, not touching the 0's in D.

I tried initially with NVLs and DECODEs, like this:

DECODE(migr.A,NULL,(NVL(C,1)),D) AS D

but I'm not getting all the records, only the D-1's.

I really don't want to relate to an extra table/step for validation, as my query result can be easily over 1 million records, but if that's the best, I'm ok.

Many thanks.

  • 1
    What *exactly* do you mean by "whenever A fields are the same, and there's more than 1 record with those, not touching the 0's in D"? – Bohemian Mar 27 '14 at 06:10
  • These records are work orders for a company. Recently they introduced two 'times', so to speak, for the same order, so now I have order A001/A580/TBA and A001/A580/PBT. This table is the registration of the orders already done to be paid by the company and D in 0 means the client already recognized that. The new time (so to say, PBT, was newly introduced last week and they are trying to pay that order double! We don't want that. – user3467255 Mar 27 '14 at 11:35
  • That explains the context, but I still don't know exactly what you want. What does "not touching" mean? What does "with those" mean"? If it's hard to put into words, try posting sample rows before and after the update, showing various edge cases so we can understand what you want to happen. – Bohemian Mar 27 '14 at 12:25

0 Answers0