Hi, I have a simliar issue with my code. This is TSQL code which I can transfer to teradata. The issue is:
I have a table with CUSTID, ORDERID, ORDERDATE. I wrote a code but it is giving me the difference between first two transcations for each customer. I am trying to find the difference between every two consequetive transactions made by each customer. Please help.
select a.custid, a.orderid, b.orderid as orderid2, a.orderdate as date1, b.orderdate as date2,
row_number() over(partition by a.custid order by a.custid, a.orderid) as order_rank
from Sales.Orders as a inner join Sales.Orders as b
where a.orderid <b.orderid) t1
where t1.order_rank <2
order by custid, order_rank;