SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 {Resolved}Need help getting max date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

zwheeler
Starting Member

USA
25 Posts

Posted - 03/28/2012 :  16:34:39  Show Profile  Reply with Quote
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


Edited by - zwheeler on 03/29/2012 12:09:36

tkizer
Almighty SQL Goddess

USA
37134 Posts

Posted - 03/28/2012 :  16:37:25  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

India
52317 Posts

Posted - 03/28/2012 :  16:39:28  Show Profile  Reply with Quote
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

USA
25 Posts

Posted - 03/29/2012 :  12:09:11  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.33 seconds. Powered By: Snitz Forums 2000