SQL Query to get ToTime where max(EndMeasDepth) and min(ReportNo) and Min(SeqNo)

  • Please help. The query is as far as I can get. Here is the query in txt format. Since the max(EndMeasDepth) is NULL or 0, I want to get the column [ToTime] with min(ReportNo) and min(SeqNO)

    Query:

    select D.wellid, min(ToTime) as [ToTime]from

    DailyOperations d

    INNER JOIN (select WellID, max(ISNULL(EndMeasDepth,0)) AS MaxEndMeasDepth

    from DailyOperations Group By WellID) DM on DM.WellID = D.WellID and

    DM.MaxEndMeasDepth = ISNULL(D.EndMeasDepth,0)

    where D.JobID ='Drilling' and D.wellid ='102193.01'

    GROUP BY D.WellID

    order by D.WellID

    2019-10-03_9-28-08

     

  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply