<cfquery ...>
select
max(eHistory.eHistory_ID) as LastRow_ID,
max(eHistory.Date_Out) as columnofinterest
from eHistory
where eHistory.Equip_ID = 2
group by eHistory.eHistory_ID, eHistory.Date_Out
</cfquery>
</untested>
Doug
Gonzo Rock wrote:
>using MS-SQL Server here and.... I am trying to find the largest
>eHistory_ID record and its associated Date_Out column value for the set of
>records whose Equip_ID = 2
>
><cfquery name="LastRowID" datasource="#attributes.datasource#">
> select max(eHistory.eHistory_ID) as LastRow_ID, eHistory.Date_Out as
>columnofinterest
> from eHistory
> where eHistory.Equip_ID = 2
></cfquery>
>
>is getting this error:
>
>Column 'eHistory.Date_Out' is invalid in the select list because it is not
>contained in an aggregate function and there is no GROUP BY clause.
>
>I am guessing there is some sub select sort of statement I should be using
>but... alas not hitting on it.
>
>Thanks,
>Gonz
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

