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.
Author |
Topic |
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2013-12-10 : 05:42:09
|
HI All I need some help Aim – Get the latest [hst_date_processed] for every [hst_merchnum]My query so far is SELECT top 5[hst_merchnum] ,[hst_date_processed] FROM [FDMS].[dbo].[Fact_Financial_History] where hst_merchnum = '878001897' group by [hst_merchnum],hst_date_processed which return the following results hst_merchnum hst_date_processed878001897 2011-12-01878001897 2012-07-01878001897 2011-11-01878001897 2011-02-01878001897 2011-05-01However results i need are ;hst_merchnum hst_date_processed878001897 2012-07-01 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-10 : 05:45:43
|
[code]SELECT [hst_merchnum],MAX([hst_date_processed]) AS LatestProcessedDateFROM [FDMS].[dbo].[Fact_Financial_History]where hst_merchnum = '878001897'group by [hst_merchnum][/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2013-12-10 : 05:50:19
|
HI visakh16Thats great for individual merchant, what happens when i want to search the whole database ?Would Max function still work ? |
 |
|
|
|
|