how to return only ids that dont contain a date

  Kiến thức lập trình

How would I return only ids that do not have a date associated
example:

id    date 
1      1/2/2023
1      null
1      null
2      null
2      null
3      null
3      null
4      3/5/2024
4      6/4/2024
4      null

In the example I would return only ids 2 and 3 since there is no date associated at all with them.

The sql I tried is below however it does not bring back correct information is it will bring back the ID that has both nulls and a date.

SELECT distinct
    f.[ID],
    f.[CID],
    f.[FirstName],
    f.[LastName],
    f.[FA],
    f.[Active],
    f.[Username],
    s.LastEval
    

    into #tempF
    FROM  f
    inner join  s
    on s.ID = f.ID
    inner join  ss
    on ss.ID = s.ID

    where  FirstName is not null 
    and 
    LastName NOT LIKE '%[^a-zA-Z ]%'
    and LastName is not null
    and FA = @fa
    and f.Active = @active
    and ss.T = @t
    
    order by LastName, FirstName



    select Count(CID), 
           ID,
            CID,
            FirstName,
            LastName,
            LastEval
    from #tempF
    where LastEval is  null
    group by 
     ID,
            CID,
            FirstName,
            LastName,
            LastEval

            order by LastName, FirstName
    drop table #tempF

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT