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
 Select How to get the Max Date???

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2011-08-17 : 09:28:27
Hi,

I would like to get the MAX requestdate.There are couple of records but I need only the Max requestdate.

Best Regards

here is the sample statement:

select RequestDate,Vendor,Item from Table1 where vendor = '1' and Item = 1

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-17 : 09:35:18
just the requestdate ?

select max(requestdate)
from Table1



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2011-08-17 : 09:40:20
Nope I need the max requestdate with vendor and item also but I need only 1 record.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-17 : 09:50:57
[code]
select top 1 *
from Table1
order by requestdate desc
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-17 : 09:51:08

do u mean this? if not post your expected output for a sample data

select vendor ,item ,max(requestdate)
from Table1
group by vendor ,item



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

Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2011-08-17 : 09:53:12
khtan's reply is what I want. It produces only one result. visakh16, your reply brings more than one result.
Thanks everybody.
Go to Top of Page
   

- Advertisement -