How to find out average salary of employee with total number of employees in each department
suppose person salary is 3000 and number of employees in his department are 4 then his salary is 750(average salary)
so two queries involved here,one which will count how many employees in each department and another query which will find out average salary of employees from their department count.
These type of queries are done using with clause
with dept_cnt as(
select deptno,count(empno) emp_cnt from emp group by deptno)select empno,sal/emp_cnt from emp e ,dept_cnt c where e.deptno=c.deptno;
Pattern searching in scala is very easy, it could be done using match keyword . Successful match will be evaluated by case keyword which provides alternatives for match pattern.
println(“Enter SI or CI”)
case _ =>”Wrong choice”
println(s”Interest calc $intcalc”);