Code Word SQL (6)

Source: Internet
Author: User

  
 
  1. --外连接(用(+)书写)
  2. --查询出所有部门的雇员信息
  3. select b.deptno, b.dname, a.* from emp a, dept b where a.deptno(+)=b.deptno ;
  4. --查询出所有部门的雇员数
  5. select b.deptno, count(*) from emp a, dept b where a.deptno(+)=b.deptno group by b.deptno;
  6. select b deptno count ( empno from emp a , Span class= "PLN" > Dept b where a deptno (+) = b deptno group by b deptno -- count for non-empty fields, Pay special attention to
  7. --查询出所有部门的职位为经理的雇员数
  8. Selectb.Deptno,Count(empno) fromEMP a,Dept Bwherea.Deptno(+)=b.Deptno anda.Job(+)=' MANAGER ' Group byb.Deptno;
  9. --查询出没有雇员的部门
  10. select b.* from emp a, dept b where a.deptno(+)=b.deptno and a.empno is null;
It's worth mentioning that Oracle 9i

From for notes (Wiz)

Code Word SQL (6)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.