Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. SQL Server
  3. Question
SQL Server

How to get MAX DATE With NULL VALUE?

Asked by Anne Bell Jul 12, 2021 1.6K views 1 answer
Share

About this question

 Trying to get the max date from my table, i can't retrieve the value when the date is null. Sample : the following table :+----+--------+------+------------------------+ | id | parent | Date | +----+--------+------+------------------------+ | 1 | Alex | 2018-10-01 00:00:00.0000000 | | 1 | TIM | 2012-11-07 00:00:00.0000000 | | 3 | Cath | NULL | +----+--------+------+------------------------+ To get the max date I’m using the following: select id, Parent, Date From Table T1 Where Date = (select Max(Date) from Table T2 where T1.id= T2.id ) Which works fine for the id = 1 But for the id = 3 it's not working

The result is : 1 | Alex | 2018-10-01 00:00:00.0000000 Any ideas Why?


Your answer

1 Answer

More SQL Server discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest SQL Server Blogs

Guides, tips and career advice on SQL Server from JanBask experts.