Hello, I currently have an update statement that reads Update #comparetemp Set #comparetemp.MaxID = #MultiTicket.IDTSDetail from #Multiticket inner join #CompareTemp on #CompareTemp.FSEID = #multiticket.FSEID Where (#MultiTicket.IDTSDetail < #comparetemp.MaxID and @StartDate <= #multiticket.DateEstDeparture) and (#multiticket.DateEstDeparture < #comparetemp.DateCustomerConfirm and #CompareTemp.FSEID = #multiticket.FSEID)
This statement works, but I need to change one of the WHERE clauses to include an expression with an AGGREGATE, something like Update #comparetemp Set #comparetemp.MaxID = #MultiTicket.IDTSDetail from #Multiticket inner join #CompareTemp on #CompareTemp.FSEID = #multiticket.FSEID Where (max(#MultiTicket.IDTSDetail) < #comparetemp.MaxID and @StartDate <= #multiticket.DateEstDeparture) and (#multiticket.DateEstDeparture < #comparetemp.DateCustomerConfirm and #CompareTemp.FSEID = #multiticket.FSEID)
This does not work because you cannot have aggregates in WHERE clause, only HAVING clause and HAVING clause are only usable in a select statement as far as I know.My question is, can I make a SELECT statement that does the same thing as my update statement above? Or is there any other way to acomplish what I'm trying to do?