> GoalHistory (GoalHistoryID, GoalID, GoalStatus, GoalStageOfChange, 
> GoalHistoryDate)
> 
> Given the GoalID, how do I write a query that will return both the 
> "oldest" and "newest" entry in GoalHistory.  I would have no 
> problem doing 
> this in two queries, but have not had luck condensing it into 
> a single query.

Assuming you're on SQL Server, the following should work...

SELECT TOP 1 * FROM GoalHistory
WHERE GoalID = #goalID#
ORDER BY GoalHistoryDate DESC
UNION
SELECT TOP 1 * FROM GoalHistory
WHERE GoalID = #goalID#
ORDER BY GoalHistoryDate ASC


-----------------------------------
Justin D. Scott
Vice President
Sceiron Interactive, Inc.
www.sceiron.com

[EMAIL PROTECTED]
941.378.5341 - office
941.320.2402 - mobile
877.678.6011 - facsimile


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2187
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to