"Tracking"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DonLi

    "Tracking"

    OK. For DDL, please refer to the classical Northwind ORDERS table,
    problem/challenge, find the longest duration (start_date and
    end_date), during which, no orders were placed.

    FYI, column names by the order of colid per syscolumns:
    OrderID
    CustomerID
    EmployeeID
    OrderDate
    RequiredDate
    ShippedDate
    ShipVia
    Freight
    ShipName
    ShipAddress
    ShipCity
    ShipRegion
    ShipPostalCode
    ShipCountry

    Any idea/approach? TIA.
  • Malcolm Cook

    #2
    Re: "Tracking& quot;

    Does this help?


    select o1.OrderDate, o2.OrderDate, DATEDIFF( day, o1.OrderDate,
    o2.OrderDate) as days_between
    from dbo.Orders o1, dbo.Orders o2
    where o1.OrderDate < o2.OrderDate
    and not exists
    (select * from dbo.Orders o3
    where o3.OrderDate < o2.OrderDate
    and o1.OrderDate < o3.OrderDate)
    group by o1.OrderDate, o2.OrderDate
    order by days_between desc


    "DonLi" <donli@yahoo.co m> wrote in message
    news:9a172893.0 404051228.4a675 061@posting.goo gle.com...[color=blue]
    > OK. For DDL, please refer to the classical Northwind ORDERS table,
    > problem/challenge, find the longest duration (start_date and
    > end_date), during which, no orders were placed.
    >
    > FYI, column names by the order of colid per syscolumns:
    > OrderID
    > CustomerID
    > EmployeeID
    > OrderDate
    > RequiredDate
    > ShippedDate
    > ShipVia
    > Freight
    > ShipName
    > ShipAddress
    > ShipCity
    > ShipRegion
    > ShipPostalCode
    > ShipCountry
    >
    > Any idea/approach? TIA.[/color]


    Comment

    Working...