Submit Search
Upload
Lesson02 学会使用WHERE、ORDER BY子句
•
0 likes
•
926 views
R
renguzi
Follow
Oracle OCP考试之007第2章,学会使用WHERE、ORDER BY子句!
Read less
Read more
Technology
Economy & Finance
Business
Report
Share
Report
Share
1 of 38
Download now
Download to read offline
Recommended
Les02
Les02
Akmal Rony
Lesson06 使用子查询
Lesson06 使用子查询
renguzi
Lesson05 从多表中查询数据
Lesson05 从多表中查询数据
renguzi
Oracle examples
Oracle examples
MaRwa Samih AL-Amri
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
Achmad Solichin
Les06
Les06
Abrianto Nugraha
Les09
Les09
Abrianto Nugraha
Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句
renguzi
Recommended
Les02
Les02
Akmal Rony
Lesson06 使用子查询
Lesson06 使用子查询
renguzi
Lesson05 从多表中查询数据
Lesson05 从多表中查询数据
renguzi
Oracle examples
Oracle examples
MaRwa Samih AL-Amri
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
Achmad Solichin
Les06
Les06
Abrianto Nugraha
Les09
Les09
Abrianto Nugraha
Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句
renguzi
Les06
Les06
Akmal Rony
Les02
Les02
Abrianto Nugraha
Les08
Les08
Abrianto Nugraha
Les11
Les11
Abrianto Nugraha
Lesson04 学会使用分组函数
Lesson04 学会使用分组函数
renguzi
Les10
Les10
Abrianto Nugraha
plsql Les07
plsql Les07
sasa_eldoby
Restricting and sorting data
Restricting and sorting data
Syed Zaid Irshad
Chinabankppt
Chinabankppt
newrforce
Understanding
Understanding
Arun Gupta
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
SQL- Introduction to MySQL
SQL- Introduction to MySQL
Vibrant Technologies & Computers
Subquery & view
Subquery & view
Roxana Tadayon
Les04
Les04
Akmal Rony
Frank Rodenbaugh Portfolio
Frank Rodenbaugh Portfolio
FrankRodenbaugh
Advanced SQL Webinar
Advanced SQL Webinar
Ram Kedem
Advanced Sql Training
Advanced Sql Training
bixxman
SQA server performance tuning
SQA server performance tuning
Duy Tan Geek
Sql tutorial
Sql tutorial
amitabros
sql language
sql language
moman abde
Restricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data Base
Salman Memon
Les02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.ppt
DrZeeshanBhatti
More Related Content
What's hot
Les06
Les06
Akmal Rony
Les02
Les02
Abrianto Nugraha
Les08
Les08
Abrianto Nugraha
Les11
Les11
Abrianto Nugraha
Lesson04 学会使用分组函数
Lesson04 学会使用分组函数
renguzi
Les10
Les10
Abrianto Nugraha
plsql Les07
plsql Les07
sasa_eldoby
Restricting and sorting data
Restricting and sorting data
Syed Zaid Irshad
Chinabankppt
Chinabankppt
newrforce
Understanding
Understanding
Arun Gupta
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
Achmad Solichin
SQL- Introduction to MySQL
SQL- Introduction to MySQL
Vibrant Technologies & Computers
Subquery & view
Subquery & view
Roxana Tadayon
Les04
Les04
Akmal Rony
Frank Rodenbaugh Portfolio
Frank Rodenbaugh Portfolio
FrankRodenbaugh
Advanced SQL Webinar
Advanced SQL Webinar
Ram Kedem
Advanced Sql Training
Advanced Sql Training
bixxman
SQA server performance tuning
SQA server performance tuning
Duy Tan Geek
Sql tutorial
Sql tutorial
amitabros
sql language
sql language
moman abde
What's hot
(20)
Les06
Les06
Les02
Les02
Les08
Les08
Les11
Les11
Lesson04 学会使用分组函数
Lesson04 学会使用分组函数
Les10
Les10
plsql Les07
plsql Les07
Restricting and sorting data
Restricting and sorting data
Chinabankppt
Chinabankppt
Understanding
Understanding
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
SQL- Introduction to MySQL
SQL- Introduction to MySQL
Subquery & view
Subquery & view
Les04
Les04
Frank Rodenbaugh Portfolio
Frank Rodenbaugh Portfolio
Advanced SQL Webinar
Advanced SQL Webinar
Advanced Sql Training
Advanced Sql Training
SQA server performance tuning
SQA server performance tuning
Sql tutorial
Sql tutorial
sql language
sql language
Similar to Lesson02 学会使用WHERE、ORDER BY子句
Restricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data Base
Salman Memon
Les02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.ppt
DrZeeshanBhatti
Les02.ppt
Les02.ppt
gfhfghfghfgh1
Subqueries -Oracle DataBase
Subqueries -Oracle DataBase
Salman Memon
Lesson08
Lesson08
renguzi
Les02
Les02
Vijay Kumar
Lesson07
Lesson07
renguzi
Les07
Les07
Abrianto Nugraha
Les01
Les01
Akmal Rony
Les05
Les05
Akmal Rony
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
Achmad Solichin
Les06
Les06
Vijay Kumar
Les06
Les06
Sudharsan S
plsql les01
plsql les01
sasa_eldoby
Les02
Les02
Sudharsan S
ADVANCE SQL-"Sub queries"
ADVANCE SQL-"Sub queries"
Ankit Surti
plsql Les08
plsql Les08
sasa_eldoby
e computer notes - Restricting and sorting data
e computer notes - Restricting and sorting data
ecomputernotes
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
gaurav koriya
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Salman Memon
Similar to Lesson02 学会使用WHERE、ORDER BY子句
(20)
Restricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data Base
Les02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.ppt
Les02.ppt
Les02.ppt
Subqueries -Oracle DataBase
Subqueries -Oracle DataBase
Lesson08
Lesson08
Les02
Les02
Lesson07
Lesson07
Les07
Les07
Les01
Les01
Les05
Les05
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
Les06
Les06
Les06
Les06
plsql les01
plsql les01
Les02
Les02
ADVANCE SQL-"Sub queries"
ADVANCE SQL-"Sub queries"
plsql Les08
plsql Les08
e computer notes - Restricting and sorting data
e computer notes - Restricting and sorting data
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Recently uploaded
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
Fwdays
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
Miki Katsuragi
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
Scott Keck-Warren
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
Enterprise Knowledge
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
carlostorres15106
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
Mattias Andersson
costume and set research powerpoint presentation
costume and set research powerpoint presentation
phoebematthew05
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
gvaughan
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
shyamraj55
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April Automation LPDG
MarianaLemus7
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Alex Barbosa Coqueiro
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
Florian Wilhelm
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Pixlogix Infotech
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Mark Billinghurst
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Sergiu Bodiu
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
Kalema Edgar
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
2toLead Limited
Recently uploaded
(20)
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
costume and set research powerpoint presentation
costume and set research powerpoint presentation
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April Automation LPDG
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
Lesson02 学会使用WHERE、ORDER BY子句
1.
Oracle OCP 考试系列培训
之 1Z0-007 Lesson2 Lesson2 www.OracleOnLinux.cn 2-1 Copyright © 2011, www.OracleOnLinux.cn . Part rights reserved.
2.
2
Restricting and Sorting Data 2-2 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
3.
Objectives
After completing this lesson, you should be able to do the following: • Limit the rows that are retrieved by a query • Sort the rows that are retrieved by a query 2-3 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
4.
Limiting Rows Using
a Selection EMPLOYEES … “retrieve all employees in department 90”90” 2-4 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
5.
Limiting the Rows
That Are Selected • Restrict the rows that are returned by using the WHERE clause: SELECT *|{[DISTINCT] column|expression [alias],...} FROM table [WHERE condition(s)]; • The WHERE clause follows the FROM clause. clause. 2-5 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
6.
Using the WHERE
Clause SELECT employee_id, last_name, job_id, department_id FROM employees WHERE department_id = 90 ; 2-6 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
7.
Character Strings and
Dates • Character strings and date values are enclosed by single quotation marks. • Character values are case-sensitive , and date case-sensitive, values are format-sensitive . format-sensitive. • The default date format is DD-MON-RR. SELECT last_name, job_id, department_id FROM employees WHERE last_name = 'Whalen' ; 2-7 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
8.
Comparison Operators
Operator Meaning = Equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to <> Not equal to BETWEEN Between two values (inclusive) ...AND... IN(set) Match any of a list of values LIKE Match a character pattern IS NULL Is a null value 2-8 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
9.
Using Comparison Conditions
SELECT last_name, salary FROM employees WHERE salary <= 3000 ; 2-9 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
10.
Using the BETWEEN
Condition Use the BETWEEN condition to display rows based on a range of values: SELECT last_name, salary FROM employees WHERE salary BETWEEN 2500 AND 3500 ; Lower limit Upper limit 2-10 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
11.
Using the IN
Condition Use the IN membership condition to test for values in a list: SELECT employee_id, last_name, salary, manager_id FROM employees WHERE manager_id IN (100, 101, 201) ; 2-11 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
12.
Using the LIKE
Condition • Use the LIKE condition to perform wildcard searches of valid search string values. • Search conditions can contain either literal characters or numbers: – % denotes zero or many characters. – _ denotes one character. SELECT first_name FROM employees WHERE first_name LIKE 'S%' ; 2-12 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
13.
Using the LIKE
Condition • You can combine pattern-matching characters: SELECT last_name FROM employees WHERE last_name LIKE '_o%' ; • You can use the ESCAPE identifier to search for the actual % and _ symbols. SELECT employee_id,last_name,job_id FROM employees WHERE job_id LIKE '%SA_%' ESCAPE '' ; 2-13 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
14.
Using the LIKE
Condition • You can combine pattern-matching number: SELECT last_name,salary FROM employees WHERE salary LIKE '1____' ; 2-14 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
15.
Using the NULL
Conditions Test for nulls with the IS NULL operator. SELECT last_name, manager_id FROM employees WHERE manager_id IS NULL ; SELECT last_name, manager_id FROM employees WHERE manager_id = NULL ; SELECT last_name, manager_id FROM employees WHERE manager_id <> NULL ; 2-15 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
16.
Logical Conditions
Operator Meaning AND Returns TRUE if both component conditions are true OR Returns TRUE if either component condition is true NOT Returns TRUE if the following condition is false 2-16 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
17.
Using the AND
Operator AND requires both conditions to be true: SELECT employee_id, last_name, job_id, salary FROM employees WHERE salary >=10000 AND job_id LIKE '%MAN%' ; 2-17 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
18.
Using the OR
Operator OR requires either condition to be true: SELECT employee_id, last_name, job_id, salary FROM employees WHERE salary >= 10000 OR job_id LIKE '%MAN%' ; 2-18 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
19.
Using the NOT
Operator SELECT last_name, job_id FROM employees WHERE job_id NOT IN ('IT_PROG', 'ST_CLERK', 'SA_REP') ; SELECT last_name, job_id FROM employees WHERE NOT (job_id IN ('IT_PROG', 'ST_CLERK', 'SA_REP')) ; 2-19 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
20.
Rules of Precedence
Operator Meaning 1 Arithmetic operators 2 Concatenation operator 3 Comparison conditions 4 IS [NOT] NULL, LIKE, [NOT] IN NULL, LIKE, 5 [NOT] BETWEEN 6 Not equal to 7 NOT logical condition 8 AND logical condition 9 OR logical condition You can use parentheses to override rules of precedence. 2-20 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
21.
Rules of Precedence
SELECT last_name, job_id, salary FROM employees WHERE job_id = 'SA_REP' 1 OR job_id = 'AD_PRES' AND salary > 15000; SELECT last_name, job_id, salary FROM employees WHERE (job_id = 'SA_REP' 2 OR job_id = 'AD_PRES') 'AD_PRES') AND salary > 15000; 2-21 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
22.
Using the ORDER
BY Clause • Sort retrieved rows with the ORDER BY clause: – ASC: ascending order, default ASC: – DESC: descending order DESC: • The ORDER BY clause comes last in the SELECT statement: statement: SELECT last_name, job_id, department_id, hire_date FROM employees ORDER BY hire_date ; … 2-22 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
23.
Sorting
• Sorting in descending order: SELECT last_name, job_id, department_id, hire_date FROM employees ORDER BY hire_date DESC ; 1 • Sorting by column alias: SELECT employee_id, last_name, salary*12 annsal salary* FROM employees 2 ORDER BY annsal ; • Sorting by multiple columns: SELECT last_name, department_id, salary FROM employees 3 ORDER BY department_id, salary DESC; 2-23 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
24.
Substitution Variables
... salary = ? … … department_id = ? … ... last_name = ? ... I want to query different values. 2-24 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
25.
Substitution Variables
• Use iSQL*Plus substitution variables to: SQL* – Temporarily store values with single-ampersand ( &) (& and double-ampersand (&&) substitution &&) • Use substitution variables to supplement the following: – WHERE conditions – ORDER BY clauses – Column expressions – Table names – Entire SELECT statements 2-25 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
26.
Using the &
Substitution Variable Use a variable prefixed with an ampersand ( &) to prompt the user for a value: SELECT employee_id, last_name, salary, department_id FROM employees WHERE employee_id = &employee_num ; 2-26 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
27.
Using the &
Substitution Variable 101 1 2 2-27 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
28.
Character and Date
Values with Substitution Variables Use single quotation marks for date and character values: SELECT last_name, department_id, salary *12 salary* FROM employees WHERE job_id = '&job_title' ; 2-28 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
29.
Specifying Column Names,
Expressions, and Text SELECT employee_id, last_name, job_id,&column_name FROM employees WHERE &condition ORDER BY &order_column ; salary salary > 15000 last_name 2-29 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
30.
Using the &&
Substitution Variable Use the double ampersand ( &&) if you want to reuse the variable value without prompting the user each time: SELECT employee_id, last_name, job_id, &&column_name FROM employees ORDER BY &column_name ; … 2-30 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
31.
Using the iSQL*Plus
DEFINE Command SQL* • Use the iSQL*Plus DEFINE command to create and SQL* assign a value to a variable. • Use the iSQL*Plus UNDEFINE command to remove SQL* a variable. DEFINE employee_num = 200 SELECT employee_id, last_name, salary, department_id FROM employees WHERE employee_id = &employee_num ; UNDEFINE employee_num 2-31 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
32.
Using the VERIFY
Command Use the VERIFY command to toggle the display of the substitution variable, both before and after iSQL*Plus SQL* replaces substitution variables with values: SET VERIFY ON SELECT employee_id, last_name, salary, department_id FROM employees WHERE employee_id = &employee_num; old 3: WHERE employee_id = &employee_num new 3: WHERE employee_id = 200 2-32 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
33.
Summary
In this lesson, you should have learned how to: • Use the WHERE clause to restrict rows of output: – Use the comparison conditions – Use the BETWEEN, IN, LIKE, and NULL conditions BETWEEN, IN, LIKE, – Apply the logical AND, OR, and NOT operators AND, OR, • Use the ORDER BY clause to sort rows of output: SELECT *|{[DISTINCT] column|expression [alias],...} FROM table [WHERE condition(s)] [ORDER BY {column, expr, alias} [ASC|DESC]] ; • Use ampersand substitution in iSQL*Plus to SQL* restrict and sort output at run time 2-33 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
34.
Practice 2: Overview
This practice covers the following topics: • Selecting data and changing the order of the rows that are displayed • Restricting rows by using the WHERE clause • Sorting rows by using the ORDER BY clause • Using substitution variables to add flexibility to your SQL SELECT statements 2-34 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
35.
Practice 2
Q1:The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) LAST_NAME VARCHAR2 (25) JOB_ID VARCHAR2(10) You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQL statement do you use? A. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_%' ESCAPE ''; B. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_'; C. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_' ESCAPE ""; D. SELECT employee_id, last_name, job_id FROM employees WHERE job_id = '%SA_'; 2-35 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
36.
Practice 2
Q2: The STUDENT_GRADES table has these columns: STUDENT_ID NUMBER(12) SEMESTER_END DATE GPA NUMBER(4,3) The registrar requested a report listing the students' grade point averages (GPA) sorted from highest grade point average to lowest. Which statement produces a report that displays the student ID and GPA in the sorted order requested by the registrar? A. SELECT student_id, gpa FROM student_grades ORDER BY gpa ASC; B. SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa ASC; C. SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa; D. SELECT student_id, gpa FROM student_grades ORDER BY gpa; E. SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa DESC; F. SELECT student_id, gpa FROM student_grades ORDER BY gpa DESC; 2-36 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
37.
Practice 2
Q3:Evaluate these two SQL statements: SELECT last_name, salary , hire_date FROM EMPLOYEES ORDER BY salary DESC; SELECT last_name, salary , hire_date FROM EMPLOYEES ORDER BY 2 DESC; What is true about them? A. The two statements produce identical results. B. The second statement returns a syntax error. C. There is no need to specify DESC because the results are sorted in descending order by default. D. The two statements can be made to produce identical results by adding a column alias for the salary column in the second SQL statement. 2-37 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
38.
Practice 2
Q4: Examine this statement: SELECT student_id, gpa FROM student_grades WHERE gpa > &&value; You run the statement once, and when prompted you enter a value of 2.0. A report is produced. What happens when you run the statement a second time? A. An error is returned. B. You are prompted to enter a new value. C. A report is produced that matches the first report produced. D. You are asked whether you want a new value or if you want to run the report based on the previous value. 2-38 Copyright © 2011, www.OracleOnLinux.cn. Part rights reserved.
Download now