I have an exercise to do but I'm breaking my head here:
"SQL command that brings me the sum of the salaries received by employee and state in the year 2014 of the tables: SALARIES / COLLABORATORS / LOCAL_DE_TRABALHO".
I have already created and filled in all the tables, now I am trying to make the query.
SELECT SUM(VALOR_PAGO) as total_pago, NOME_COLABORADOR as colaborador,
DATA_PAGAMENTO as Data_pagamento
from COLABORADORES Inner join SALARIO
on SALARIO.ID_COLABORADOR = COLABORADORES.ID_COLABORADOR
WHERE YEAR(DATA_PAGAMENTO) = 2014
Error:
The 'COLLABORATORS.COLABORATORNAME' column is invalid in the select list because it is not contained in an aggregate function or in the GROUP BY clause.