• rp2018 - Thursday, March 1, 2018 7:23 PM

    I have a customer and order table.  There is one to many relation between customer and order table.  I have a custid = 101 and there are 5 orders in order table for it.
    I need to match each individual orders for this custid and update RecentOrders column for OrderNbr = 1.
    I need to do this in a procedure.  There can be any # of orders for a customer.
    Custid = 101
    OrderNbr = 1,2,3,4,5

    If custid=101 and (OrderNbr  =1 and order_date > 10-20-2017) or  (OrderNbr = 2 and order_date > 11-15-2017) or (OrderNbr=4 and Order_date > 12-05-2017)
    Then update OrderNbr =1 record in Orders table and set column called RecentOrders =  â€˜3 Orders’  Else 'None'

    The reason you've had no solutions is that you have not stated the problem in a way which is clear enough for people to understand and write code.
    As the previous poster suggested, we need some consumable code for setting up example tables, with insert statements to create some sample data along with desired results. The link in my signature should help you understand what is required.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.