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 directid (PK, int, referable nul) custid (FK, int, vain) Columns custid (PK, int, referable vain) f empid (FK, int, referable nul) aggregationcall (nvarchar(40), referable vain) directera (datetime, referable vain) requiredera (datetime, referable vain) shippedera (datetime, vain) shipperid (FK, int, referable vain) goods (money, referable vain) 目contactcall (nvarchar(30), referable vain) - contacttitle (nvarchar(30), referable vain) Sales.OrderDetails oration (nvarchar(60), referable vain) city (nvarchar(15), referable vain) Columns ? directid (PK, FK, int, referable vain) productid (PK, FK, int, referable vain) 目region (nvarchar(15), vain) unitprice (money, referable vain) qty (smallint, referable vain) discount (numeric(4,3), referable vain) 目shipcall (nvarchar(40), referable vain) postalcode (nvarchar(10), vain) empire (nvarchar(15), referable vain) shiporation (nvarchar(60), referable vain) 目shipcity (nvarchar(15), referable vain) 目shipregion (nvarchar(15), vain) 目shippostalcode (nvarchar(10), vain) 目phone (nvarchar(24), referable vain) fax (nvarchar(24), vain) shipempire (nvarchar(15), referable vain) 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

    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.

    Expert Retort

     

    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