Here is a "working" version of the script you have shared.
Create table customer
(custid int constraint ct_id primary key,
cust_name nvarchar(100),
cust_addr1 nvarchar(100),
cust_addr2 nvarchar(100),
city nvarchar(100),
cust_zip numeric(5),
cust_plus4 numeric(4)
);
Create table Orders
(OrderNbr int identity constraint ord_id primary key,
custid int,
Order_date datetime,
OrderQty int,
RecentOrders Nvarchar(10),
Constraint fk_custid foreign key (custid) references customer (custid)
);
Insert into customer(custid,cust_name,cust_addr1,cust_addr2,cust_zip,cust_plus4)
Values
('101','Mike Smith','111 Smith Rd',61111,1111,1111),
('102','Nicole Smith','143 Nick Lane',61112,1101,1111),
('103','Jose Gomez','155 New York St', 55555,2323,1111)
Insert into Orders(custid,order_date,orderQty,RecentOrders)
Values
(101,cast('11-22-2017' as date),20,1),
(101,cast('11-23-2017' as date),11,2),
(101,cast('11-24-2017' as date),5,3),
(101,cast('12-02-2017' as date),25,4),
(101,cast('01-09-2018' as date),2,5),
(102,cast('09-02-2017' as date),55,1),
(102,cast('11-05-2017' as date),6,2),
(103,cast('01-20-2016' as date),1,1),
(103,cast('11-10-2017' as date),13,2),
(103,cast('01-12-2018' as date),25,3)
Still not able to identify the logic to be used
You said..
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'
For 101 custid...
1,101,11-22-2017,20,1,3
2,101,11-23-2017,11,2,null
3,101,11-24-2017,5,’3,null
4,101,12-02-2017,25,4,null
5,101,01-09-2018,2,5,null
(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)
What is the rule to be used for 102 and 103 custid. Better still explain what is the general rule to be used for updating the column