SQL Functions:
Use only functions for data manupulation.
1. List employees whose name having 4 characters
2. List employees whose job is having 7 characters3. Find out howmany times letter 'S' occurs in 'qspiders'
4. List the employees whose job is having last 3 characters as 'man'
5. List employees whose job is having first 3 characters as 'man'
6. Display all the names whose name is having exactly 1 'L'
7. Display dept names which are having letter 'O'
8. Display the output as shown below,
Scott working as a clerk earns 3000 in dept 20
9. Display employees who earn odd numbered salaries
10. Display number of employees getting NULL comission.
11. Display total sal and comm drawn by dept 30
12. Count number of clerks in dept 10 and 20
13. List Department wise total salary
14. List department wise total sal only if the total sal is > 3000
15. Display job wise total salary excluding dept 30 only if the total salary is > 5000
16. Display job wise max sal only for managers, clerks, salesman working in dept 10 and 20. Sort the data by des order of the max salary.
17. Display job wise number of employees in all the department with total salary > 9000
18. Display the department number having atleast 4 employees in it
19. Display the department having only saleman in it
20 Calculate number of L in string 'HELLLLL'
21. Display all the employees whose job has a string 'MAN'
22. Display all the employees whose job starts with string 'MAN'
23. Display all the employees whose job ends with string 'MAN'
25. Display first 3 characters of ename in lower case and rest everything in upper case.
If ename is 'MITHUNASHOK' then display this as 'mitHUNASHOK'
26. Display the result from emp table as below.
SMITH is a CLERK and gets salary 2000
Here SMITH is ename column, CLERK is JOB and 2000 is SAL column and rest everything is literal strings.
Comments
Jobwise 2nd or 3rd highest sal where i'll pass 2nd dynamically
using subqueries.
SELECT * FROM EMP
WHERE SUBSTR(JOB,1,3)='MAN';
--will select all the employees who are mangers
SELECT * FROM EMP
WHERE SUBSTR(JOB,1)='MAN';
--says no rows selected
why it is so
SELECT *
FROM emp
WHERE SUBSTR(job,-3,3)='MAN';
SQL> select * from emp
where INSTR(job,'MAN') >= 1;
Allow me to show my gratitude bloggers. You guys are like unicorns. Never seen but always spreading magic. Your content is yummy. So satisfied.
I come up with a problem. In the pivot I want to summarize amount based on Hub and I want to always select the latest data of a country to add
Date Hub Country Amount
2017.01.01 Asia China 80
2017.01.02 Asia Japan 75
2017.01.03 Asia China 85
2017.01.01 Europe France 50
2017.01.05 Europe France 55
2017.01.02 Europe Turkey 20
I want to pivot to always select the latest data for each country and summarize based on Hub . Eg, for Asia that is 75+85=160, and for Europe, that is 55+20=75
It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!
Thanks,
Irene Hynes
PHP course in chennai
--select First_name from employees where length(FIRST_NAME)=4;
--select job_id, employee_id ID from employees where length(JOB_ID)=7
--select length('qspiders')-length(replace('qspiders','s','')) from dual;
--select employee_id,Job_id from employees where substr(job_id,-3,3) like'%MAN%'
--select employee_id,Job_id from employees where substr(job_id,1,3) like'%MAN%'
/*select first_name from employees
where (length(upper(first_name)))-length(replace(upper(first_name),'L',''))=1*/
--select department_name from DEPARTMENTS where DEPARTMENT_NAME like '%o%'
--select first_name,salary,mod(salary,2) from employees where mod(salary,2)!=0
--select first_name,salary,commission_pct from employees where nvl(commission_pct,'0')=0
--select sum(salary),sum(nvl(commission_pct,'0')),department_id from employees where department_id=80 group by department_id
--select job_id,count(*) from employees where department_id in (10,20,30) and job_id like '%CLERK%' group by job_id
--select (sum(salary)+sum(nvl(commission_pct,'0'))) Tsal,Department_id from employees group by DEPARTMENT_ID order by DEPARTMENT_ID asc
/*select (sum(salary)+sum(nvl(commission_pct,'0'))) Tsal,Department_id from employees
having (sum(salary)+sum(nvl(commission_pct,'0')))>=3000
group by DEPARTMENT_ID order by DEPARTMENT_ID asc*/
/*select Job_id,sum(salary)+sum(nvl(commission_pct,'0')) from employees where department_id not in(30)
having sum(salary)+sum(nvl(commission_pct,'0'))<5000
group by Job_id*/
/*select max(salary),job_id from EMPLOYEES where job_id like '%CLERK%' or Job_id like '%SA_MAN%' or Job_id like '%MGR%'
and department_id in (10,20)
group by job_id
order by Max(salary) desc*/
/*select job_id ,count(employee_id),sum(salary) from employees group by job_id
having sum(salary)>9000*/
--select department_id,count(employee_id) from employees group by DEPARTMENT_ID having count(employee_id)>=4
/*select department_id from employees where job_id like 'SA_MAN'
minus
select department_id from employees where job_id not like 'SA_MAN'*/
--select length('HELLL')-length(replace('HELLL','L','')) from dual;
--select first_name,job_id from employees where job_id like '%MAN%'
--select first_name,job_id from employees where job_id like 'MAN%'
--select first_name,job_id from employees where job_id like '%MAN'
--select 'harishKommuri',lower(substr('harishkommuri',1,3))||upper(substr('harishkommuri',4) )from dual
Ai & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai