
CREATE A SQL QUERY
The customer ID and aggregation call and the longest stay in shipping on any direct to that customer. Express the stay in weeks and assign the output in ascending direct by the stay.
As we demand to secure longest stay. So stay should in shipping item. We can furnish stay by subtracting the required era and real shipped era.
Select sc.custid , sc.companyname,
(So.shippedera – so.requireddate)/7 stay
From Sales.Orders so, sales.Customers sc
Where so.custid = sc.custid
Direct by stay