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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

selecting most recent records from

Reply to Message Icon

Name: adib
Date: July 27, 2006 at 11:40:17 Pacific
OS: aa
CPU/Ram: 1234
Product: 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




Sponsored Link
Ads by Google

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

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

-SN


0

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

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: selecting most recent records from

MySQL Select multiple tables www.computing.net/answers/dbase/mysql-select-multiple-tables/158.html

Multiple Outer Joins www.computing.net/answers/dbase/multiple-outer-joins/419.html

Generate PDF's for each record www.computing.net/answers/dbase/generate-pdfs-for-each-record/148.html