TCS Python Hackathon - Mysql Hands-on

TCS Python Hackathon - Mysql Hands-on



Q1 . Write a SQL query to the display the department name along with the count of employees in each department.

SELECT D.DEPTNAME , COUNT(*) FROM EMPLOYEES E, DEPARTMENTS D  WHERE D.DEPTID = E.DEPTID GROUP BY E.DEPTID, D.DEPTNAME;




Q2. Write a SQL query to display the name of the employees who works in the same department where employee with id 108 works.

SELECT E.ENAME FROM EMPLOYEES E , DEPARTMENTS D WHERE E.DEPTID = (SELECT E.DEPTID FROM EMPLOYEES E WHERE E.EID=108 AND E.DEPTID = D.DEPTID);




Q3. Write a SQL query to display the name of the Item ordered in the ordered with order id 4499 .

SELECT I.ITEMNAME FROM ITEMS I, ORDERS O WHERE I.ITEMID = O.ITEMID AND O.ORDERID = 4499;




Comments