1) Display details of all employees
SQL> select * from emp;
2) Display the employee no and totalsalary for all the employees. Here totalsalary = sal+comm
SQL> select empno,ename,sal,comm, sal+nvl(comm,0) total_sal from emp;
3) Display the names of all the employees who are working in department 10.
SQL> select emame from emp where deptno=10;
4) Display the employee number and name who are earning comm.
SQL> select empno,ename from emp where comm is not null;
5) Display the names of the employees who are working in the company for the past 5 years;
SQL> select ename from emp where hiredate < add_months(sysdate,-60);
6) Display the names of employees working in department number 10 or 20 or 40 and working as CLERKS,SALESMAN or ANALYST.
SQL> select ename from emp where deptno in(10,20,40) and job in('CLERKS','SALESMAN','ANALYST');
7) Display the Employee names for employees whose name ends with alaphabet S.
SQL> select ename from emp where ename like '%S';
8) Display the maximum salary being paid to CLERK.
SQL> select max(sal) from emp where job='CLERK';
9) Display the total salary drawn by an ANALYST working in department 40.
SQL> select sum(sal) from emp where job='ANALYST' and deptno=40;
10) Display the department numbers with more than three employees in each dept.
SQL> select deptno,count(deptno) from emp group by deptno having count(*)>3;
11) Display the name of the employee who earns highest salary.
SQL> select ename from emp where sal=(select max(sal) from emp);
12) Display the employee number and name for employee working as clerk and earning highest salary among clerks.
SQL> select empno,ename from emp where where job='CLERK' and sal=(select max(sal) from emp where job='CLERK');
13) Display the names of the employees who earn highest salary in their respective departments.
SQL> select ename,sal,deptno from emp e where sal in(select max(sal) from emp m where m.deptno = e.deptno);
14) Display the current '15-Aug-2012' as 15th wednesday August twenty twelve.
SQL> select to_char(to_date('15-Aug-2012'),'ddth day Month year') from dual;
15) Display the Employee name and Managers names.
SQL> select e.ename employee, m.ename manager from emp e, emp m where m.empno=e.mgr;
16) Find out top 5 earners of company.
SQL> select * from (select * from emp order by sal desc) where rownum <= 5;
17) Display the department name and total number of employees in each department.
SQL> select dname, count(ename) from emp, dept where emp.deptno=dept.deptno group by dname;
18) Increase salary of all managers by 10%.
SQL> update emp set sal=sal*1.1 where empno in (select mgr from emp);
19) Delete duplicate department from dept table.
SQL> delete from dept where rowid not in (select max(rowid) from dept group by dname);
20) Create a backup of employee table with emp_tbd name
SQL> create table emp_tbd as select * from emp;
21) Get the details of the employee getting 3rd highest salary
SQL> select * from(select e.*, dense_rank() over (order by sal desc) r from emp e) where r=3;
22) Get the details of the employees getting department wise 3rd highest salary
SQL> select * from(select empno, ename, sal, dname, dense_rank() over (partition by dname order by sal desc) r from scott.emp e, scott.dept d where e.deptno=d.deptno) where r=3;
For Questions related to C Programming: http://cbasicprogram.blogspot.in/
Related Posts
- Difference Between Cursor And Ref Cursor
- Query optimization tips for Oracle
- How to connect SQLPlus without tnsnames.ora
- Oracle Database 12c New Features for Developers
- JSON in Oracle Database with Example
- New Features for Developers in Oracle 11g
- Top 15 new features of Oracle Database 12.2 for developers
SQL> select * from emp;
2) Display the employee no and totalsalary for all the employees. Here totalsalary = sal+comm
SQL> select empno,ename,sal,comm, sal+nvl(comm,0) total_sal from emp;
3) Display the names of all the employees who are working in department 10.
SQL> select emame from emp where deptno=10;
4) Display the employee number and name who are earning comm.
SQL> select empno,ename from emp where comm is not null;
5) Display the names of the employees who are working in the company for the past 5 years;
SQL> select ename from emp where hiredate < add_months(sysdate,-60);
6) Display the names of employees working in department number 10 or 20 or 40 and working as CLERKS,SALESMAN or ANALYST.
SQL> select ename from emp where deptno in(10,20,40) and job in('CLERKS','SALESMAN','ANALYST');
7) Display the Employee names for employees whose name ends with alaphabet S.
SQL> select ename from emp where ename like '%S';
8) Display the maximum salary being paid to CLERK.
SQL> select max(sal) from emp where job='CLERK';
9) Display the total salary drawn by an ANALYST working in department 40.
SQL> select sum(sal) from emp where job='ANALYST' and deptno=40;
10) Display the department numbers with more than three employees in each dept.
SQL> select deptno,count(deptno) from emp group by deptno having count(*)>3;
11) Display the name of the employee who earns highest salary.
SQL> select ename from emp where sal=(select max(sal) from emp);
12) Display the employee number and name for employee working as clerk and earning highest salary among clerks.
SQL> select empno,ename from emp where where job='CLERK' and sal=(select max(sal) from emp where job='CLERK');
13) Display the names of the employees who earn highest salary in their respective departments.
SQL> select ename,sal,deptno from emp e where sal in(select max(sal) from emp m where m.deptno = e.deptno);
14) Display the current '15-Aug-2012' as 15th wednesday August twenty twelve.
SQL> select to_char(to_date('15-Aug-2012'),'ddth day Month year') from dual;
15) Display the Employee name and Managers names.
SQL> select e.ename employee, m.ename manager from emp e, emp m where m.empno=e.mgr;
16) Find out top 5 earners of company.
SQL> select * from (select * from emp order by sal desc) where rownum <= 5;
17) Display the department name and total number of employees in each department.
SQL> select dname, count(ename) from emp, dept where emp.deptno=dept.deptno group by dname;
18) Increase salary of all managers by 10%.
SQL> update emp set sal=sal*1.1 where empno in (select mgr from emp);
19) Delete duplicate department from dept table.
SQL> delete from dept where rowid not in (select max(rowid) from dept group by dname);
20) Create a backup of employee table with emp_tbd name
SQL> create table emp_tbd as select * from emp;
21) Get the details of the employee getting 3rd highest salary
SQL> select * from(select e.*, dense_rank() over (order by sal desc) r from emp e) where r=3;
22) Get the details of the employees getting department wise 3rd highest salary
SQL> select * from(select empno, ename, sal, dname, dense_rank() over (partition by dname order by sal desc) r from scott.emp e, scott.dept d where e.deptno=d.deptno) where r=3;
For Questions related to C Programming: http://cbasicprogram.blogspot.in/
Related Posts
- Difference Between Cursor And Ref Cursor
- Query optimization tips for Oracle
- How to connect SQLPlus without tnsnames.ora
- Oracle Database 12c New Features for Developers
- JSON in Oracle Database with Example
- New Features for Developers in Oracle 11g
- Top 15 new features of Oracle Database 12.2 for developers
it is very nice perfect notes for begi...
ReplyDeleteKeep coming for other useful posts under "Oracle SQL" tag
DeleteThis type of "quick reference" is very useful, thanks for sharing!
ReplyDeleteKeep visiting for other useful articles
DeleteThank you, Thank you, Thank you.
ReplyDeleteYour notes are extremely helpful to assist a beginner in Oracle.
Glad that it helped you, keep visiting for more useful posts.
DeleteThanks nimish - great for beginners! Found some good ones that are more advanced here:
ReplyDeleteComplex sql interview questions
Hi ! can anyone explain me about pragma init? I have gone through some articles but I am not able to understand.
ReplyDeleteThanks in advance
check this link: http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/errors.htm#i1863
DeleteGood stuff, all pretty straightforward but number 14 is wrong
ReplyDelete14) Display the current '15-Aug-2012' as 15th wednesday twenty twelve.
SQL> select to_char(to_date('15-Aug-2012'),'ddth Month year') from dual;
You would need to specify "day" to output "wednesday"
and also in question i forgot to specify august :) thanks !!!
Deletehi, I want a query, i have emp and dept table. both table having empid .I want a query to the show id whose empid is holding all dept name.
ReplyDeleteDo you mean, you want to search a employee who is member of all the departments ?
DeleteSELECT E.EID,D.EID FROM EMP E,DEPT D WHERE E.EID=D.EID;
DeleteHi,can u please send me questions on subquery
ReplyDeletequery with in a query
Deletehelpful for beginner......
ReplyDeleteReplyDelete
You can Visit for more Different kinda C-Patterns And C-Programs.
ReplyDeletehttps://www.thecprograms.com/
But he's trying none the less. I've been using Movable-type on a variety of websites for about a year and am nervous about switching to another platform. I have heard good things about . Is there a way I can import all my word press posts into it? Any help would be really appreciated!
ReplyDelete야한소설
Adapted to new systems and processes well and seeks out training to enhance knowledge, skills and abilities.
ReplyDelete스포츠마사지
Not that I am complaining, but slow loading instances times will sometimes affect your placement in google and could damage your high-quality score if advertising and marketing with AdWords. Well I am adding this RSS to my e-mail and can look out for a lot more of your respective fascinating content.
ReplyDelete출장마사지
I came to this site with the introduction of a friend around me and I was very impressed when I found your writing. I'll come back often after bookmarking! casinocommunity
ReplyDeletekadıköy bosch klima servisi
ReplyDeletekadıköy arçelik klima servisi
kartal samsung klima servisi
ümraniye samsung klima servisi
kartal mitsubishi klima servisi
ümraniye mitsubishi klima servisi
beykoz vestel klima servisi
üsküdar vestel klima servisi
beykoz arçelik klima servisi
It s a very useful page. Thank you. 2c598a47deefadd6afe78d4cdc92b537
ReplyDeletetorbali
efeler
karakopru
keciborlu
yomra
cekerek
ardesen
yesilyurt
kemalpasa
Congratulations on your article, it was very helpful and successful. 3b3ea83d4a6a0c98c6235096f1c85925
ReplyDeletewebsite kurma
sms onay
website kurma
Thank you for your explanation, very good content. 6695aa8fc7689bc87700189db0f0c688
ReplyDeletedefine dedektörü
Good content. You write beautiful things.
ReplyDeletemrbahis
hacklink
taksi
mrbahis
korsan taksi
hacklink
sportsbet
sportsbet
vbet
slot siteleri
ReplyDeletekralbet
betpark
tipobet
betmatik
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
4UE
جراحی بینی استخوانی بسته به اینکه جراحی شما چقدر پیچیده باشد و جراح شما چه چیزی را ترجیح می دهد نیاز به بی حسی موضعی همراه با آرامبخش یا بیهوشی عمومی دارد. قبل از جراحی با پزشک خود صحبت کنید که کدام نوع بیهوشی برای شما مناسب است.
ReplyDeleteجراح شما می تواند شکل استخوان یا غضروف بینی شما را به روش های مختلفی بسته به میزان نیاز به برداشتن یا اضافه کردن، ساختار بینی و مواد موجود تغییر دهد. برای تغییرات کوچک، جراح ممکن است از غضروف هایی که از عمق بیشتری از داخل بینی یا گوش گرفته شده استفاده کند. برای تغییرات بزرگتر، جراح می تواند از غضروف دنده، ایمپلنت یا استخوان سایر قسمت های بدن شما استفاده کند. پس از ایجاد این تغییرات، جراح پوست و بافت بینی را به عقب قرار می دهد و برش ها را در بینی شما بخیه می زند.
اگر دیواره بین دو طرف بینی (سپتوم) خم یا کج (انحراف) باشد، جراح نیز می تواند آن را برای بهبود تنفس اصلاح کند.
پس از جراحی، شما در اتاق ریکاوری خواهید بود، جایی که کارکنان بر بازگشت شما به حالت بیداری نظارت می کنند. ممکن است همان روز آن جا را ترک کنید یا اگر مشکلات سلامتی دیگری دارید، ممکن است یک شب بمانید.
انتخاب دکتر متخصص برای عملهای زیبایی یکی از مهمترین برای گرفتن نتیجهی بهتر است. در نتیجه، قبل از عمل حتما برای انتخاب بهترین دکتر تحقیق کنید و نمونه کارهای دکتر را ببینید.
با دکتر کامبیز ایزدپناه فوقتخصص جراحی پلاستیک، ترمیمی و زیبایی، از نتیجهی عمل خود آسوده خاطر خواهید بود. دکتر عضو سازمان نظام پزشکی ایران، عضو جامعه جراحان ایران و عضو انجمن جراحی پلاستیک ایران است. دکتر ایزدپناه تا زمان گرفتن نتیجهی ایدهآل کنار شما خواهند بود.
bilecik
ReplyDeletegebze
ısparta
şırnak
alsancak
G4Q6
salt likit
ReplyDeletesalt likit
HZİ5YH
ReplyDeleteپیج اینستاگرام دکتر ایزدپناه
drkambizizadpanah@
برای مشاهده نمونه کارها و نظرات متقاضیان، اینستاگرام دکتر ایزدپناه
( فوق تخصص جراحی پلاستیک و زیبایی ) را دنبال کنید.
چه درمانی برای جراحی بینی شکسته لازم است؟
اگر شکستگی جزئی دارید که باعث کج شدن یا بدشکل شدن بینی شما نشده است، ممکن است نیازی به درمان پزشکی حرفه ای نداشته باشید. ممکن است فقط با استفاده از یخ روی ناحیه و مصرف داروهای مسکن بدون نسخه، خوب باشید.
معمولا رشد موهای سینه در بدن آقایان طبیعی است. بیشتر آقایانی که به بهداشت و زیبایی بدن خود اهمیت میدهند و اکثر آقایان ورزشکار مایل به لیزر موهای زائد سینه هستند. خانمها معمولا کمتر دارای موهای زائد در ناحیه سینه هستند، البته نباید حساسیت به خرج داد و موی سینه باید واقعا زائد باشد و نه صرفا موی نازک. زیرا لیزر موی نازک به هیچ وجه انجام نمیپذیرد.
ReplyDeleteلیزر موهای سینه مردان