August 31, 2019 at 10:21 am
Hi,
I have a master row where OrderType is NOT NULL (Bold Row)
Problem: When on column in MasterRow is empty, then take the value from a neighbor line (same PK), update the NULL-value in the master line:
Query: Is Coalesce the right way to go over all rows and columns? There are max. 3 lines per PK.
=> If ISNULL (Master.Column) THEN take the first NOT NULL value from Neighbor lines.
order;orderType;Period;Amount;Unit;Group;incentive
441001;ONL;;0;;99;
441001;;QUATER;1;ST;;
441001;;;0;;;TV
Regards and Thanks
Nicole 🙂
August 31, 2019 at 11:13 pm
I think you could do it with LEAD or LAG on two columns and a COALESCE
September 1, 2019 at 12:21 am
My take on this would be to find and fix the code that's making this mess and then make the ORDER TYPE column NOT NULL. Actually, the best thing to do would be to have an "Order_Header" table where the ORDER TYPE only needs to be noted once and then store the details in a separate "Order_Detail" table to store the individual line items involved in the order.
--Jeff Moden
September 2, 2019 at 1:06 pm
Actually, the best thing to do would be to have an "Order_Header" table where the ORDER TYPE only needs to be noted once and then store the details in a separate "Order_Detail" table to store the individual line items involved in the order.
Glad I'm still doing it right 😉
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply