Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 {Resolved}Need help getting max date

Author  Topic 

zwheeler
Starting Member

25 Posts

Posted - 2012-03-28 : 16:34:39
Hi

i have the following query, which i thought would give me the maximum date for each record_id however, it does not.

Any assistance would be greatly appreciated:


select fk_fha_number,max(date_final_settlement) max_settlement_date
from mf_fha_claim
where date_final_settlement is not null
and fk_fha_number in ( 06435113,
07135575,
09235585,
09235599,
06235384,
10135218,
09235399,
08544032,
08435265,
08535312)

group by fk_fha_number,date_final_settlement
order by fk_fha_number



Results
fk_fha_number Max_date_settlement

06235384 1999-09-08 00:00:00.000
06235384 2004-01-30 00:00:00.000

06435113 1995-09-27 00:00:00.000

07135575 1997-05-27 00:00:00.000
07135575 2007-11-15 00:00:00.000

08435265 1999-08-03 00:00:00.000
08435265 2005-03-17 00:00:00.000
08535312 1990-06-08 00:00:00.000
08535312 2004-09-24 00:00:00.000
08544032 1999-06-24 00:00:00.000
08544032 2005-03-23 00:00:00.000
09235399 2012-02-01 00:00:00.000
09235585 2009-06-17 00:00:00.000
09235585 2009-09-22 00:00:00.000
09235599 2009-06-09 00:00:00.000
09235599 2009-09-22 00:00:00.000
10135218 2002-01-28 00:00:00.000
10135218 2005-09-30 00:00:00.000

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-03-28 : 16:37:25
group by fk_fha_number

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-28 : 16:39:28
see similar logics used here

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=173054

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

zwheeler
Starting Member

25 Posts

Posted - 2012-03-29 : 12:09:11
thank you

quote:
Originally posted by tkizer

group by fk_fha_number

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page
   

- Advertisement -