SELECT
DEPTMST.DEPTID,
DEPTMST.DEPTNAME,
DEPTMST.CREATEDT,
COUNT(USRMST.UID)
FROM DEPTMASTER DEPTMST
INNER JOIN USERMASTER USRMST ON USRMST.DEPTID=DEPTMST.DEPTID
WHERE DEPTMST.CUSTID=1000 AND DEPTMST.STATUS='ACT
I have tried several combination but I keep getting error
Column 'DEPTMASTER.DeptID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
I also add group by but it's not working
GROUP BYfollowed by all the column names which are not in aggregate functions eg.GROUP BY DEPTMST.DEPTID,DEPTMST.DEPTNAME ...GROUP BYstatement required for your code to run is database engine specific - SQLServer requires all, MySQL requires one. Please add your RDBMS as a tag. However, so long as you are grouping byDEPTMST.DEPTID, DEPTMST.DEPTNAME, DEPTMST.CREATEDTit looks like it would work.