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 |
|
nbalraj
Starting Member
21 Posts |
Posted - 2011-11-08 : 16:24:35
|
| Hi Allbelow is the table records11/08/2011 John Doe10/08/2011 John Doe02/08/2011 John Doe11/10/2011 Mary Fine05/10/2011 Mary Fine01/10/2011 Mary FineI need only the max row11/08/2011 John Doe11/10/2011 Mary FineHow can i get this. Thanks for any help. |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-11-08 : 16:52:17
|
| [code]SELECT MIN(<Date Column>), <Name Column>FROM <Table Name>GROUP BY <Name Column>[/code] |
 |
|
|
nbalraj
Starting Member
21 Posts |
Posted - 2011-11-08 : 17:06:12
|
| sorry, i forgot to add one more conditionbelow is the updated table records11/08/2011 John Doe elec10/08/2011 John Doe mechanical engg02/08/2011 John Doe prod engg11/10/2011 Mary Fine engg05/10/2011 Mary Fine mech01/10/2011 Mary Fine prdI need only the max row11/08/2011 John Doe elec11/10/2011 Mary Fine enggHow can i get this. Thanks for any help. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-09 : 01:07:44
|
| [code]SELECT t.*FROM table tINNER JOIN (SELECT MAX(DateField) AS MaxDate,Namefield FROM table GROUP BY nameField) t1ON t1.NameField = t.NameField AND t1.MaxDate = t.DateField[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|