Oracle Single-Table query statements

Source: Internet
Author: User

Test forms using the Oracle database:

--single-Table query data Syntax Select (query) * All/query fields, multiple fields, separating from table name--find information for all employeesSelect *  fromscott.emp;Select *  fromDept;--query all employee numbers, names and positions specify field names to find dataSelectEmpno,ename,job fromEMP;--Check the number, name and annual salary of all employeesSelect *  fromEMP;SelectEmpno,ename,sal* A  fromEMP;--using an operator with a query does not modify the original data--It's just an operation at the time of the query, showing a new data table .SelectEmpno,ename,sal* A  fromEMP;--calculate the? Provides a virtual table, dual--dual is a virtual table that is designed for testing use--You can alias a fieldSelect 1+1  asResult1 fromdual;SelectSysdate asDATES fromdual;--alias Sal*12 changed to income as can be omitted--' single quotation mark for string ' "is used when aliases are used, if aliases contain special characters use" "to wrap upSelectEmpno,ename,sal* AAnnual salary fromEMP;--Query the names, positions, and salaries of all users and display them in the following manner--Name: xxx, job: xxx, Salary: XXX--string concatenation using | | Connection not +Select 'Name:'||Ename||', Position:'||Job||', Salary:'||Sal Info fromEMP;--want to show all the positions, can not duplicate the elimination of duplicates--to re-use distinctSelect distinctJob,ename fromEMP;--Sort Ascending and descending (ASC desc)--sort needs to specify sort fields by default ascending ASC--numeric date string types can be sortedSelect *  fromEmpOrder  byJobASC;--In descending order of salary, if the salary is the same, then the old employee is discharged to the back (date descending)--Sort by multiple fields, order by as long as write once, subsequent sort fields are used, separatedSelectEmpno,ename,hiredate,sal fromEmpOrder  bySaldesc, HireDatedesc; --Check all employee numbers, names, annual salary, and sort by yearly salary--sorting can be used with aliasesSelectEmpno,ename,sal* AIncome fromEmpOrder  byIncomedesc;

Oracle Single-Table query statements

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.