Code Word SQL (2)

Source: Internet
Author: User

Classic format of select basic composition
  
 
  1. select * from emp;
  2. select * from emp where empno>8000;
  3. select empno ename sal comm from EMP where Sal < comm
  4. select Deptno count (*) from emp group by Deptno ;
  5. select Deptno sum ( sal ) Total_sal from EMP where job = ' MANAGER ' group by Span class= "PLN" > Deptno ;
  6. select job count ( distinct deptno ) from EMP where Mgr is not null group by Span class= "PLN" > Job order by job ;
  
 
  1. select job count ( distinct deptno ) from EMP where Mgr is not null group by Span class= "PLN" > Job order by count ( distinct deptno ) desc job
  2. select job count ( distinct deptno ) Uniq_deptno Span class= "KWD" >from emp where Mgr is not null group by job Order by Uniq_deptno desc job ;
  3. select deptno, to_char(hiredate,‘yyyy‘),count(*) from emp group by deptno,to_char(hiredate,‘yyyy‘);
Sorting is very resource-intensive, so it is the last execution, and you should keep this in mind.
Here's a look at a demand.




From for notes (Wiz)

Code Word SQL (2)

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.