To avoid using subselect in the select
clause, you can cross-reference table data using one ranking per client.
So:
SELECT
SOURCE.ID,
SOURCE.CLIENTE,
SOURCE.FASE,
SOURCE.DATA,
DATEDIFF(DAY, QUERY.DATA, SOURCE.DATA) DIAS
FROM (SELECT RANK() OVER (PARTITION BY CLIENTE ORDER BY FASE) AS RANKING,
T.ID,
T.CLIENTE,
T.FASE,
T.DATA FROM Teste T) SOURCE
LEFT JOIN (SELECT RANK() OVER (PARTITION BY CLIENTE ORDER BY CLIENTE, FASE) AS RANKING,
T.CLIENTE,
T.FASE,
T.DATA FROM Teste T) QUERY ON QUERY.CLIENTE = SOURCE.CLIENTE AND (QUERY.RANKING = SOURCE.RANKING - 1)
Depending on the real scenario where you intend to apply the performance gain while avoiding subselect, it can be very interesting.
This example is available in SQL Fiddle