My Tables :-
Groups:
GID,Gname,category,DeptID
Departments:
DeptID,GID,duration,SID,Year
Trying to fetch the below.. but its returning duplicate count in no of slots and duration.I am looking to fetch all departments ID's with sum of duration & count of slots for each dept ID's in a single query.
Please correct my query.
Thank you in advance.
SELECT Departments.GID,Departments.DeptID,Groups.Gname,Groups.category,
SUM(Departments.DURATION) as Total_Duration,count(Departments.SID) as Total_No_OF_Slots,Departments.Year
FROM Groups,Departments
WHERE Groups.GID=Departments.GID AND Groups.DeptID=Departments.DeptID AND Departments.Year='LIVE-16-17'
GROUP BY Departments.GID,Departments.DeptID,Groups.Gname,Groups.category,Departments.Year
ORDER BY Departments.GID;