ALTER VIEW [dbo].[ExtendedOrderHeaderView] AS SELECT H.* ,dbo.PreviousOrderDate(H.custID) as [PreviousOrderDate] ,RealOrderCount = (SELECT count(o.orderno) FROM OrderHeaders O WHERE (O.custid=H.CustID) and (OrderType=0)) ,RealLastOrderDate = (SELECT max(o.createdat) from OrderHeaders O WHERE (o.custid=H.custid) and (OrderType=0)) ,DaysSincePreviousOrder = DATEDIFF(DAY,h.[CreatedAt],[PreviousOrderDate]) FROM dbo.OrderHeaders as H GO
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.