I think at one point I tried that. I just did again, though, and came across a problem.
The query does not work unless I remove the first "Order By" clause. I assume this is because you can only order the "results" and not each individual query. I'm playing around with a join that would give me both values in a single row, but not having much luck. At 09:09 AM 2/27/2005, you wrote: > > 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:2188 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=89.70.6 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
