Morning chaps and chapettes,
Just working on a bit of SQL to feed a crystal report, but I can't get it to behave the way I'd like.
At the moment, I have this little snippet:
SQL
SELECTol.OrderLineID,isnull(olp2.SectionStartOrderLineID,olp.SectionStartOrderLineID)FROMOrderLineolWITH(NOLOCK)LEFTJOINOrderLinePriceInfoolpWITH(NOLOCK)ONol.OrderLineID=olp.OrderLineIDLEFTJOINOrderLinePriceInfoolp2WITH(NOLOCK)ONol.CreatedFromOrderLineID=olp2.OrderLineIDWHEREol.OrderID=69524ORDERBYol.LineNumber
The idea is that it returns an OrderLineID, then checks to see which section it belongs to. If it doesn't belong to a section, it checks the OrderLineID it was originally created from (CreatedFromOrderLineID) and checks whetherthatbelonged to a section.
What you end up with is a set of results like so:
Text
OrderLineID...