Unix Technical Forum

Query assistance

This is a discussion on Query assistance within the SQL Server forums, part of the Microsoft SQL Server category; --> I am trying to pull some "notes" from a sql database.....the notes that are put into the database come ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 07:38 PM
cory.craig@integris-health.com
 
Posts: n/a
Default Query assistance

I am trying to pull some "notes" from a sql database.....the notes that
are put into the database come via the web and the user is entering it
for a certain task. they are stored in their own table and field and
get assigned and incremental ID #.

I want to be able to pull up the latest entry to the task, not all of
the notes just the latest one.. The entry does get a timestamp in the
field so I am thinking I might be able to look at that field
somehow.... Right now my query shows all notes / entries for the task.

I am an intermediate sql query guy so I hopefully expained enough to
get assistance.

Let me know if you need to know more.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 07:38 PM
cory.craig@integris-health.com
 
Posts: n/a
Default Re: Query assistance

Here is the sample data...
iwmsjn_Note iwmsjn_Timestamp
working on SQL queries for reports 2/17/2006 4:20:34 PM
Researching a report for Sheri 2/28/2006 4:35:21 PM
Working on Reports / Queries 3/3/2006 3:34:04 PM
Test Delete 3/8/2006 1:45:30 PM

I only want the one that says "Test Delete" stamped for TODAY....not
the others.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 07:38 PM
datagal@msn.com
 
Posts: n/a
Default Re: Query assistance

This should do it...

select iwmsjn_Note
from [tablename] a
where iwmsjn_Timestamp = (select max(iwmsjn_Timestamp)
from [tablename] b
where a.[ID] = b.[ID])

Jody

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:50 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com