{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# sql02 - 2 2 Restricting and Sorting Data 2-2 Objectives...

This preview shows pages 1–10. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2 2 Restricting and Sorting Data 2-2 Objectives After completing this lesson, you should After completing this lesson, you should be able to do the following: be able to do the following: • Limit the rows retrieved by a query • Sort the rows retrieved by a query 2-3 Limiting Rows Using a Selection "…retrieve all "…retrieve all employees employees in department 10" in department 10" EMP EMP EMPNO ENAME JOB ... DEPTNO 7839 KING PRESIDENT 10 7698 BLAKE MANAGER 30 7782 CLARK MANAGER 10 7566 JONES MANAGER 20 ... EMP EMP EMPNO ENAME JOB ... DEPTNO 7839 KING PRESIDENT 10 7782 CLARK MANAGER 10 7934 MILLER CLERK 10 2-4 Limiting Rows Selected • Restrict the rows returned by using the WHERE clause. • The WHERE clause follows the FROM clause. SELECT [DISTINCT] {*, column [ alias ], . ..} FROM table [WHERE condition(s) ]; 2-5 Using the WHERE Clause SQL> SELECT ename, job, deptno 2 FROM emp 3 WHERE job='CLERK'; ENAME JOB DEPTNO---------- --------- ---------JAMES CLERK 30 SMITH CLERK 20 ADAMS CLERK 20 MILLER CLERK 10 2-6 Character Strings and Dates • Character strings and date values are enclosed in single quotation marks • Character values are case-sensitive and date values are format-sensitive • Default date format is ' DD-MON-YY ' SQL> SELECT ename, job, deptno 2 FROM emp 3 WHERE ename = 'JAMES'; 2-7 Comparison Operators Operator = > >= < <= <> Meaning Equal to Greater than Greater than or equal to Less than Less than or equal to Not equal to 2-8 Using the Comparison Operators SQL> SELECT ename, sal, comm 2 FROM emp 3 WHERE sal<=comm; ENAME SAL COMM---------- --------- ---------MARTIN 1250 1400 2-9 Other Comparison Operators...
View Full Document

{[ snackBarMessage ]}

### Page1 / 26

sql02 - 2 2 Restricting and Sorting Data 2-2 Objectives...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online