Twitter Interview Question for Software Engineers


Country: United States
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
1
of 1 vote

SELECT 
    Department.name, 
    COUNT(Employee.id)
FROM 
    Department
LEFT JOIN 
    Employee ON Department.dept_id = Employee.dept_id
GROUP BY 
    Department.dept_id, 
    Department.name
ORDER BY 
    COUNT(Employee.id) DESC, 
    Department.name

Looking for interview experience sharing and coaching?

Visit aonecode.com for private lessons by FB, Google and Uber engineers

Our ONE TO ONE class offers

SYSTEM DESIGN Courses (highly recommended for candidates for FLAG & U)
ALGORITHMS (conquer DP, Greedy, Graph, Advanced Algos & Clean Coding),
latest interview questions sorted by companies,
mock interviews.

Our students got hired from G, U, FB, Amazon, LinkedIn and other top tier companies after weeks of training.

Feel free to email us aonecoding@gmail.com with any questions. Thanks!

- aonecoding September 05, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select 
	d.Name, 
	count(e.ID) as empCount
from 
	Department d
left outer join 
	Employee e on d.DEPT_ID = e.DEPT_ID
group by 
	d.Name
order by 
	empCount desc, 
	d.Name

- Anonymous September 06, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select 
	d.Name, 
	count(e.ID) as empCount
from 
	Department d
left outer join 
	Employee e on d.DEPT_ID = e.DEPT_ID
group by 
	d.Name
order by 
	empCount desc, 
	d.Name

- mrrezaian September 06, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select d.name, count(e.id) over (partition by d.dept_id) as total_employees
from employee e join department d
on e.dept_id= d.dept_id
order by total_employees desc, d.name

- Kanu October 30, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{select d.name, count(e.id) over (partition by d.dept_id) as total_employees
from employee e join department d
on e.dept_id= d.dept_id
order by  total_employees desc, d.name

}

- Kanu October 30, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT
Department.name,
COUNT(Employee.id)
FROM
Department
LEFT JOIN
Employee ON Department.dept_id = Employee.dept_id
GROUP BY
Department.dept_id,
Department.name
ORDER BY
COUNT(Employee.id) DESC,
Department.name

- Anonymous November 07, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT D.Name, A.empCnt
FROM DEPARTMENT AS D
CROSS APPLY (SELECT COUNT(*) AS empCnt
FROM EMPLOYEE AS E
WHERE E.DEPT_ID = D.DEPT_ID
) AS A
ORDER BY A.empCnt DESC, D.Name

- Mahabubul Islam November 19, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT 	D.Name,  A.empCnt
FROM 	DEPARTMENT AS D 
		CROSS APPLY (SELECT COUNT(*) AS empCnt
					 FROM  EMPLOYEE AS E
					 WHERE E.DEPT_ID = D.DEPT_ID
					) AS A
ORDER BY A.empCnt DESC, D.Name

- Mahabubul Islam November 19, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

SELECT D.department_id, D.department_name, Count(E.EMPLOYEE_ID)
FROM departments D
Left OUTER JOIN employees E
ON
E.department_id = D.department_id
Group by D.department_id, D.department_name
Having Count(E.EMPLOYEE_ID)<3
Order by Count(E.EMPLOYEE_ID) DESC, D.department_name;

- Anonymous June 18, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select d.dname,count(empno)
from dept d,emp e
where d.DEPTNO=e.DEPTNO(+)
group by d.DEPTNO,d.dname
ORDER BY
COUNT(e.EMPNO) DESC,
d.dname;

- Anoosha Shetty October 26, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

select d.dname,count(empno)
from dept d,emp e
where d.DEPTNO=e.DEPTNO(+)
group by d.DEPTNO,d.dname
ORDER BY 
    COUNT(e.EMPNO) DESC, 
    d.dname

- Anoosha Shetty October 26, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Select d.name as "Department Name",Count(e.id) as "No of Employees" from Department d
left outer join Employees e
on d.dept_id=e.dept_id
group by d.name
order by count(e.id) desc,d.name asc;

- itsmeashishsingh November 17, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is assuming that there is no department for unstaffed..

select coalease(d.name,'Unstaffed'),count(e.id) as No_of_Employees from Employee e
inner join Department d
on e.dept_id=d.dept_id
group by d.name
order by No_of_Employees desc,d.name asc;

- itsmeashishsingh February 04, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Select temp.dept_name, temp.total from (Select d.dept_id, d.dept_name, count(emp_id) as total from dept_p d LEFT OUTER JOIN emp_p e on d.dept_id=e.dept_id group by dept_id,dept_name)temp order by temp.total desc, temp.dept_name;

- Vaibhav February 24, 2019 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More