I have a query to get count of records in a table and getting below error :
ERROR: column "emp.last_login_time" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: ...in') LIKE '%Delhi%')) ORDER BY emp.last_log...
Below is my query:
Select count(*) FROM Employee AS emp
WHERE emp.last_login_time >= 0
AND emp.last_login_time <= 1751060669383
AND (((emp.employee_data->>'city') LIKE '%Delhi%'
AND emp.employee_data->>'empID' is null)
OR ((emp.employee_data->>'employeeType') LIKE '%Permanent%' AND (emp.employee_data->>'city') LIKE '%Delhi%')
OR ((emp.employee_data->>'employeeType') IN ('Permanent Employee') AND (emp.employee_data->>'city') LIKE '%Delhi%'))
ORDER BY emp.last_login_time DESC, emp.empID DESC LIMIT 100
Since this is a count query, I am not using a group by clause which is right. I am not sure why Postgres is still throwing this error. Can you someone pitch in?