0
Guys, I’m trying to perform the SUM according to the query below, however, the following error occurs. " It is not possible to perform an aggregation function on an expression that contains an aggregation or a sub-allowance." The output is to exit this way.
Total_Horas MesID Mes Ano
60 1 Janeiro 2018
Consultation
select
sum(dbo.FN_CALC_HORAS_UTEIS(s.SolData,min(l.LogData))),datepart(month,s.SolData) MesID,datename(month,s.soldata) Mes,datepart(year,s.soldata) Ano
from
Solicitacao S
left join usuario U
on (U.UsuID = S.UsuIDResponsavel)
left join Status ST
on S.SolStatus = ST.CodStatus
left join Log L on L.LogSolID = s.SolID and (l.LOGDESCRICAO like '%1057%' or l.LOGDESCRICAO like '%3343%')
where S.proid in (2) and S.UsuIDResponsavel in(1776) and s.SolStatus <> 9 and convert(date,s.soldata) between '01-01-2018' and getdate()--and s.SolID = 65513
group by datepart(month,s.SolData),datename(month,s.soldata) ,datepart(year,s.soldata)
Faustino, the following message occurred in his first query: "The 'Request.Weld' column is invalid in the selection list because it is not contained in an aggregation function or in the GROUP BY clause." . And in the second.
– Renan Bessa
I think we are close then! Soldata is at GROUP BY! So we have to pass to FUNNTION the whole date!
– Wilson Faustino
Just one more question! The function receives what in the first parameter?
– Wilson Faustino
I edited the answer, try without the line of the first GROUP BY
– Wilson Faustino
the function receives the working hours between a certain period, in which case it is between the opening date (s. weld) and the minimum log date(l. logdata).
– Renan Bessa