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
 Finding max date.

Author  Topic 

MageshkumarM
Yak Posting Veteran

61 Posts

Posted - 2012-02-24 : 02:00:59
Hi all,

I have a doubt with this.

Table data
idno date particulare
1 12/01/2012 A
2 13/01/2012 B
3 14/01/2012 C

I want to find the max date and show the idno.

Thanks,
Magesh.M
http://mageshkumarm.blogspot.com/

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-02-24 : 02:37:12
[code]
select top 1 * from data order by date desc
[/code]


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

Go to Top of Page

Azhar Khan
Starting Member

3 Posts

Posted - 2012-02-24 : 05:06:39
create table [dbo].[TEST](
[idno][nvarchar](50) NULL,
[date]date NULL,
[particulare][nvarchar](50) NULL,
)
on [PRIMARY];

insert into TEST values(1,'01/12/2012','A');
insert into TEST values(2,'01/13/2012','B');
insert into TEST values(3,'01/14/2012','C');

select top 1 date,idno from TEST order by date desc;

just run this SQL's in your database and get result:-

Date idno
1/14/2012 3


Azhar khan
Go to Top of Page
   

- Advertisement -