February 28, 2011 at 2:22 pm
Hey everyone,
Hoping someone can help me out with this post. I'm still relatively new to SQL, so any help someone can provide is appreciated. I have a table that every that I'm trying to obtain the maximum completed date out of. I've gotten down to only completed records and their date, plus their primary key. My result set looks like the below:
Object_IDField_NameCmpltdDate
6174789 date 1/9/2008
7121500 date 2/14/2008
6738580 date 3/10/2008
9961973 date 4/18/2008
12255168 date 5/9/2008
4973823 date 11/14/2007
5624018 date 12/17/2007
I want to return the max record for this so I can include this as a subquery in a larger SP. Here is the SQL I have so far:
SELECT fd.Object_ID,
fd.Field_Name,
Convert(DATETIME,fd.Field_Value) AS 'CmpltdDate'
FROM dbo.vw_1041_Form_Data fd WITH(NOLOCK)
JOIN dbo.vw_1041_Event_Tracking et WITH(NOLOCK) ON
fd.Object_ID=et.ID
WHERE et.Event_Name Like '%Monthly%'
AND fd.Field_Name Like 'date'
GROUP BY
fd.Field_Name,
fd.Object_ID,
fd.Field_Value
Can anyone help me with where the max statement should be?
February 28, 2011 at 2:37 pm
Please post the DDL for your table and the DML for your data.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply