SQL : Using count function to count records from two tables and returns the same even if count is zero
I have two tables: Employee and Department Fields of Employee : id, name, dept_id Fields of Department: dept_id, name I need a query which fetches me department name and number of employees per department along with it, even if number of employees for a department is zero. I tried the query below, but it returns only those departments which have number of employees more than zero. select d.name, count(e.id) as
RELATED QUESTIONS
RELATED TOPICS
ABOUT ANSWERBAG
Answerbag wants to provide a service to people looking for answers and a good conversation. Ask away and we will do our best to answer or find someone who can.We try to vet our answers to get you the most acurate answers.
Copyright 2023, Wired Ivy, LLC