Good morning, how do I make my clause affect only one (1) field in my search? For example:
$query = DB::table('proventosdesc as proven')
->join('calculo_rh as calc', 'proven.pessoaId', '=', 'calc.pessoaId')
->join('pessoa', 'calc.pessoaId', '=', 'pessoa.id')
->select('pessoa.nome as a', 'calc.cargo as b', 'calc.departamento as c',
DB::raw("SUM(proven.valor) as d"))
->groupby('proven.pessoaId');
I want to leave a condition only for the last field "proven.value" imposing only the return of type P, would be something like this:
$query = DB::table('proventosdesc as proven')
->join('calculo_rh as calc', 'proven.pessoaId', '=', 'calc.pessoaId')
->join('pessoa', 'calc.pessoaId', '=', 'pessoa.id')
->select('pessoa.nome as a', 'calc.cargo as b', 'calc.departamento as c',
DB::raw("SUM(proven.valor) as d")->where('proven.tipo, '=', 'P')
->groupby('proven.pessoaId');
That way it does not work, passing the where internally in the given field.
I did not want this condition to affect all the select but only the last field, because I will need to make another condition in the same way for another field of the same select ... Could someone please help me? I am willing to offer any information if the question was not clear!