Computing.Net > Forums > Database > selecting most recent records from

selecting most recent records from

Reply to Message Icon

Original Message
Name: adib
Date: July 27, 2006 at 11:40:17 Pacific
Subject: selecting most recent records from
OS: aa
CPU/Ram: 1234
Model/Manufacturer: www
Comment:

Table: <Table_Max id="1" note="some note1" date="2006-07-07T19:39:46" ID_NEW="1"/><Table_Max id="2" note="somenote2" date="2006-07-07T19:37:46" ID_NEW="1"/><Table_Max id="3" note="somenote3" date="2006-07-08T19:35:46" ID_NEW="2"/><Table_Max id="4" note="somenote4


select distinct id_new into #temp from Table_Max

DECLARE ac CURSOR FOR
SELECT * from #temp


OPEN ac

-- Perform the first fetch and store the values in variables.
-- Note: The variables are in the same order as the columns
-- in the SELECT statement.

DECLARE @id int
FETCH NEXT FROM ac
INTO @id

-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
declare @maxP as datetime

set @maxP = ( select MAX([date]) from Table_Max where id_new = @id)
-- Concatenate and display the current values in the variables.
declare @note as nvarchar(4000)

set @note = ( select note from Table_Max where id_new = @id and [date] = @maxP)

PRINT 'Last modified: ' + cast(@maxP as nvarchar(4000))+ ' for ID = ' + cast(@id as nvarchar(4000)) + ' NOTE = ' + @note

-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM ac
INTO @id
END

CLOSE ac
DEALLOCATE ac
GO



Report Offensive Message For Removal


Response Number 1
Name: SN
Date: July 30, 2006 at 20:55:02 Pacific
Reply: (edit)

So...What's the question???

-SN


Report Offensive Follow Up For Removal

Response Number 2
Name: cupidc
Date: August 15, 2006 at 07:24:45 Pacific
Reply: (edit)

http://www.cisco-cert.com/Windows_XP_General/620974-Windows-XP-4GB-RAM-showing-2GB-RAM


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: selecting most recent records from 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge