I have the following table structure:
cod_chestionar IT HR data_lansare
3GDH 9.83 9.32 6.12.2017
4XW6 9.14 9.89 6.11.2017
5Y7R 9 10 10.11.2017
DGVR 9.05 9.9 6.12.2017
And I would want to obtain the following:
cod_chestionar dep nota an luna data_lansare
3GDH IT 9.83 2017 12 6.12.2017
4XW6 IT 9.14 2017 11 6.11.2017
5Y7R IT 9 2017 11 10.11.2017
DGVR IT 9.05 2017 12 6.12.2017
3GDH HR 9.32 2017 12 6.12.2017
4XW6 HR 9.89 2017 11 6.11.2017
5Y7R HR 10 2017 11 10.11.2017
DGVR HR 9.9 2017 12 6.12.2017
My query to obtain the first format is:
SELECT DISTINCT
Cod_Chestionar,
ROUND(AVG(CAST(Intrebare1 AS FLOAT)), 2) AS It,
ROUND(AVG(CAST(Intrebare2 AS FLOAT)), 2) AS Hr,
CAST(DAY(Data_Introducere) AS VARCHAR)+'.'+CAST(MONTH(Data_Introducere) AS VARCHAR)+'.'+CAST(YEAR(Data_Introducere) AS VARCHAR) AS Data_Lansare
FROM Personal AS P,
Suport_Depart,
Email_Suport AS E
WHERE E.Cod_Email = Suport_Depart.Cod
AND E.Email = P.Email
AND Intrebare1 != 'Nu interactionez'
AND Intrebare2 != 'Nu interactionez'
GROUP BY Cod_Chestionar,
Data_Introducere;
Please don't mind the old sql format, I wrote it on a hurry. Any suggestion would be appreciated.