I need to insert tqo more colums in the below query where instead of Max or Min , I need to get the first non null value. Can any some one help?SELECT t1.ProcessSegmentS95Id as 'Segment',t2.ProcessSegmentS95Id as 'ChildSegment',MIN(t1.StartTime) as 'SegmentStartTime' , MAX(t1.EndTime)as 'SegmentEndTime',MIN(t2.StartTime) as 'ChildSegmentStartTime' , MAX(t2.EndTime)as 'ChildSegmentEndTime' FROM (SELECT * FROM [SOADB].[dbo].[SegmentResponse] where Depth = 0 ) t1 INNER join (SELECT * FROM [SOADB].[dbo].[SegmentResponse] where Depth=1) t2 on t1.SegmentResponseId = t2.ParentSegmentResponseId group by t1.ProcessSegmentS95Id ,t2.ProcessSegmentS95Id order by t1.ProcessSegmentS95Id ,t2.ProcessSegmentS95Id