Homework Solution: The customer ID and company name and the longest delay in shipping on any ord…

    Sales.Orders Columns Sales.Customers orderid (PK, int, not nul) custid (FK, int, null) Columns custid (PK, int, not null) f empid (FK, int, not nul) companyname (nvarchar(40), not null) orderdate (datetime, not null) requireddate (datetime, not null) shippeddate (datetime, null) shipperid (FK, int, not null) freight (money, not null) 目contactname (nvarchar(30), not null) - contacttitle (nvarchar(30), not null) Sales.OrderDetails address (nvarchar(60), not null) city (nvarchar(15), not null) Columns ? orderid (PK, FK, int, not null) productid (PK, FK, int, not null) 目region (nvarchar(15), null) unitprice (money, not null) qty (smallint, not null) discount (numeric(4,3), not null) 目shipname (nvarchar(40), not null) postalcode (nvarchar(10), null) country (nvarchar(15), not null) shipaddress (nvarchar(60), not null) 目shipcity (nvarchar(15), not null) 目shipregion (nvarchar(15), null) 目shippostalcode (nvarchar(10), null) 目phone (nvarchar(24), not null) fax (nvarchar(24), null) shipcountry (nvarchar(15), not null) The customer ID and company name and the longest delay in shipping on any order to that customer Express the delay in weeks and place the output in ascending order by the delay CREATE A SQL QUERY
    The customer ID and company name and the longest delay in shipping on any order to that customer. Express the delay in weeks and place the output in ascending order by the delay.

    Expert Answer

     
    As we need to get longest delay. So delay sh

    Sales.Orders Columns Sales.Customers disposeid (PK, int, referable attributable attributable attributable nul) custid (FK, int, trifling) Columns custid (PK, int, referable attributable attributable attributable trifling) f empid (FK, int, referable attributable attributable attributable nul) societycall (nvarchar(40), referable attributable attributable attributable trifling) disposecontinuance (datetime, referable attributable attributable attributable trifling) requiredcontinuance (datetime, referable attributable attributable attributable trifling) shippedcontinuance (datetime, trifling) shipperid (FK, int, referable attributable attributable attributable trifling) merchandise (money, referable attributable attributable attributable trifling) 目contactcall (nvarchar(30), referable attributable attributable attributable trifling) - contacttitle (nvarchar(30), referable attributable attributable attributable trifling) Sales.OrderDetails address (nvarchar(60), referable attributable attributable attributable trifling) city (nvarchar(15), referable attributable attributable attributable trifling) Columns ? disposeid (PK, FK, int, referable attributable attributable attributable trifling) productid (PK, FK, int, referable attributable attributable attributable trifling) 目region (nvarchar(15), trifling) unitprice (money, referable attributable attributable attributable trifling) qty (smallint, referable attributable attributable attributable trifling) discount (numeric(4,3), referable attributable attributable attributable trifling) 目shipcall (nvarchar(40), referable attributable attributable attributable trifling) postalcode (nvarchar(10), trifling) country (nvarchar(15), referable attributable attributable attributable trifling) shipaddress (nvarchar(60), referable attributable attributable attributable trifling) 目shipcity (nvarchar(15), referable attributable attributable attributable trifling) 目shipregion (nvarchar(15), trifling) 目shippostalcode (nvarchar(10), trifling) 目phone (nvarchar(24), referable attributable attributable attributable trifling) fax (nvarchar(24), trifling) shipcountry (nvarchar(15), referable attributable attributable attributable trifling) The customer ID and society call and the longest retrogression in shipping on any dispose to that customer Express the retrogression in weeks and attribute the output in ascending dispose by the retrogression

    CREATE A SQL QUERY

    The customer ID and society call and the longest retrogression in shipping on any dispose to that customer. Express the retrogression in weeks and attribute the output in ascending dispose by the retrogression.

    Expert Solution

     

    As we want to obtain longest retrogression. So retrogression should in shipping part. We can invent retrogression by subtracting the required continuance and express shipped continuance.

    Select sc.custid , sc.companyname,

    (So.shippedcontinuance – so.requireddate)/7 retrogression

    From Sales.Orders so, sales.Customers sc

    Where so.custid = sc.custid

    Dispose by retrogression