I have these two tables. Can somebody help with a query, to get the record from @transact which has min (createddate). I have millions of records in both the tables.
declare @main table (ID int)
insert into @main (ID)
select 1
declare @transact table (ID int, Notes varchar(10),createddate datetime)
insert into @transact (ID,Notes,createddate)
select 1,'A','2013-04-24 00:23:17.077' union
select 1,'B','2013-04-23 00:20:44.687' union
select 1,'C','2013-04-29 09:33:13.167' union
select 1,'D','2013-04-25 00:20:17.970'
Thanks,
NSG
NSG12