I had a question yesterday that I thought I had a perfect answere for. Well I got the perfect answere considering the information I gave the experts but I found one more problem with my code.
Here is the question from yesterday : http://www.experts-exchange.com/Programming/Languages/SQL_Syntax/Q_23471738.html#a21768768
The code i'm using is the last one Sdstuber posted:
- time_val >= 1
THEN TO_CHAR (FLOOR ( next_time
|| ' '
|| TO_CHAR ( TRUNC (SYSDATE)
+ ( next_time
- time_val), 'hh24:mi') time_diff
FROM (SELECT COST, date_val, time_val,
LEAD (time_val, 1) OVER (ORDER BY time_val) next_time
WHERE COST = 0;
Now, my problem is that there is one additional column called TYPE that takes values 1 ,2 or 3.
So my data table is like this
The code above compares two values of Time_val if the first line has a Cost = 0, but I need it to compare values of Time_val between a line with Cost = 0 and the next line with the same TYPE number.
Thanks in advance.