I have a table with
Columns:OrderID int PK
Department varchar(100)
OrderDate date
OrderQty int
OrderTotal int.
I want to add two orderdates
from orderid 1 and 5. I tried to make self join but it return 0.
select p.orderdate,datediff(p.orderdate,m.orderdate) as d
from orders as p inner join
orders as m on p.OrderID = m.OrderID where p.OrderID =1 and
m.OrderID =5
2
Answers
should give you the expected result
If you really wont get period of dates with two orders, it can be done by serveral ways, for example: