Oracle SQL Query Help needed for below -
i have table below :
id ref num type time stamp ------------------------------ 1 456 x time 1 2 456 y updated timestamp 3 678 x time 3 4 678 y updated timestamp
i need in building query shall give me result below :
ref num type time difference ------------------------------------ 456 x (timestamp diff between type x , type y ref num) 678 y (timestamp diff between type x , type y ref num)
you can conditional aggregation:
select t.refnum, (max(case when type = 'x' timestamp end) - max(case when type = 'y' timestamp end) ) typetimestampdiff t group t.refnum;
Comments
Post a Comment