bordoloi and bock chapter 4 : adding power to queries

31
Bordoloi and Bordoloi and Bock Bock Chapter 4 : Adding Power to Chapter 4 : Adding Power to Queries Queries

Upload: prosper-mcdaniel

Post on 31-Dec-2015

221 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Chapter 4 : Adding Power to QueriesChapter 4 : Adding Power to Queries

Page 2: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

LOGICAL OPERATORSLOGICAL OPERATORS (AND, OR, AND NOT) (AND, OR, AND NOT)

• AND : Joins two or more conditions, and AND : Joins two or more conditions, and returns results only when returns results only when allall of the conditions of the conditions are true.are true.

• OR : Joins two or more conditions, and returns OR : Joins two or more conditions, and returns results when results when any any of the conditions are true.of the conditions are true.

• NOT : Negates the expression that follows it.NOT : Negates the expression that follows it.

Page 3: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

AND OPERATORAND OPERATOR

SELECT emp_last_name "Last Name", SELECT emp_last_name "Last Name", emp_first_name "First Name",emp_first_name "First Name",emp_gender "Gender"emp_gender "Gender"FROM employeeFROM employeeWHERE emp_gender = 'F' AND emp_last_name > ‘E'WHERE emp_gender = 'F' AND emp_last_name > ‘E'ORDER BY emp_last_name;ORDER BY emp_last_name;Last Name First Name GenderLast Name First Name Gender---------- ------------- ---------------- ------------- ------Joyner Suzanne FJoyner Suzanne FMarkis Marcia FMarkis Marcia FPrescott Sherri FPrescott Sherri F

Page 4: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

OR OPERATOROR OPERATOR

SELECT emp_last_name "Last Name",SELECT emp_last_name "Last Name",emp_first_name "First Name",emp_first_name "First Name",emp_gender "Gender"emp_gender "Gender"FROM employeeFROM employeeWHERE emp_gender = 'F' OR emp_last_name > 'M'WHERE emp_gender = 'F' OR emp_last_name > 'M'ORDER BY emp_last_name;ORDER BY emp_last_name;

Last Name First Name GenderLast Name First Name Gender--------------- --------------- --------------------- --------------- ------Joyner Suzanne FJoyner Suzanne FMarkis Marcia FMarkis Marcia FPrescott Sherri FPrescott Sherri FZhu Waiman MZhu Waiman M

Page 5: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

NOT OPERATORNOT OPERATOR

SELECT emp_last_name "Last Name", SELECT emp_last_name "Last Name", emp_first_name "First Name",emp_first_name "First Name",emp_dpt_number "Dept"emp_dpt_number "Dept"FROM employeeFROM employeeWHERE NOT emp_dpt_number = 7WHERE NOT emp_dpt_number = 7ORDER BY emp_last_name;ORDER BY emp_last_name;

Last Name First Name DeptLast Name First Name Dept--------------- --------------- -------------------- --------------- -----Amin Hyder 3Amin Hyder 3Bordoloi Bijoy 1Bordoloi Bijoy 1Joyner Suzanne 3Joyner Suzanne 3Markis Marcia 3Markis Marcia 3  

Page 6: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Combining OR and AND OperatorsCombining OR and AND Operators

• When the AND operator is combined with OR, When the AND operator is combined with OR, the Oracle server will evaluate the condition the Oracle server will evaluate the condition connected by the AND connected by the AND firstfirst before any before any conditions connected with OR.conditions connected with OR.

• Parenthesis must be used to force an order of Parenthesis must be used to force an order of operation. operation.

Page 7: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Combining OR and AND OperatorsCombining OR and AND Operators

SELECT emp_last_name "Last Name",SELECT emp_last_name "Last Name",emp_first_name "First Name",emp_first_name "First Name",emp_dpt_number "Dept", emp_gender "Gender" emp_dpt_number "Dept", emp_gender "Gender" FROM employeeFROM employeeWHERE emp_last_name > 'E' AND emp_gender = 'F‘WHERE emp_last_name > 'E' AND emp_gender = 'F‘OR emp_dpt_number = 1OR emp_dpt_number = 1ORDER BY emp_last_name;ORDER BY emp_last_name;  Last Name First Name Dept GenderLast Name First Name Dept Gender--------------- -------------- ----- --------------------- -------------- ----- ------Bordoloi Bijoy 1 MBordoloi Bijoy 1 MJoyner Suzanne 3 FJoyner Suzanne 3 FMarkis Marcia 3 FMarkis Marcia 3 FPrescott Sherri 7 FPrescott Sherri 7 F

Page 8: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Combining OR and AND Operators Combining OR and AND Operators

SELECT emp_last_name "Last Name", SELECT emp_last_name "Last Name", emp_first_name "First Name",emp_first_name "First Name",emp_dpt_number "Dept", emp_gender "Gender" emp_dpt_number "Dept", emp_gender "Gender" FROM employee FROM employee WHERE emp_last_name > 'E' AND WHERE emp_last_name > 'E' AND (emp_gender = 'F' OR emp_dpt_number = 1)(emp_gender = 'F' OR emp_dpt_number = 1)ORDER BY emp_last_name; ORDER BY emp_last_name;   Last Name First Name Dept GenderLast Name First Name Dept Gender--------------- --------------- ----- --------------------- --------------- ----- ------Joyner Suzanne 3 FJoyner Suzanne 3 FMarkis Marcia 3 FMarkis Marcia 3 FPrescott Sherri 7 FPrescott Sherri 7 F

Page 9: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

LISTS (IN AND NOT IN)LISTS (IN AND NOT IN)

• There are two operators that are designed for testing to There are two operators that are designed for testing to determine if data stored in a table column is either in or not determine if data stored in a table column is either in or not in a list or set of values.in a list or set of values.

• These are the IN and NOT IN operators. These are the IN and NOT IN operators.

• These operators greatly simplify the task of writing queries These operators greatly simplify the task of writing queries that might otherwise require a large number of either OR that might otherwise require a large number of either OR logical operators or an unwieldy use of the NOT logical logical operators or an unwieldy use of the NOT logical operator. operator.

Page 10: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using IN OperatorUsing IN Operator

SELECT emp_last_name "Last Name", emp_first_name "First SELECT emp_last_name "Last Name", emp_first_name "First Name",Name", emp_salary "Salary"emp_salary "Salary"FROM employeeFROM employeeWHERE emp_salary = 43000 OR emp_salary = 30000 OR WHERE emp_salary = 43000 OR emp_salary = 30000 OR emp_salary = 25000emp_salary = 25000ORDER BY emp_salary;ORDER BY emp_salary;  Last Name First Name SalaryLast Name First Name Salary--------------- --------------- -------------------------- --------------- -----------Markis Marcia $25,000.00Markis Marcia $25,000.00Amin Hyder $25,000.00Amin Hyder $25,000.00Prescott Sherri $25,000.00Prescott Sherri $25,000.00Bock Douglas $30,000.00Bock Douglas $30,000.00Joyner Suzanne $43,000.00Joyner Suzanne $43,000.00Zhu Waiman $43,000.00Zhu Waiman $43,000.006 rows selected.6 rows selected.

Page 11: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using IN OperatorUsing IN Operator

SELECT emp_last_name "Last Name", emp_first_name "First Name",SELECT emp_last_name "Last Name", emp_first_name "First Name",emp_salary "Salary"emp_salary "Salary"FROM employee FROM employee WHERE emp_salary IN (43000, 30000, 25000)WHERE emp_salary IN (43000, 30000, 25000)ORDER BY emp_salary;ORDER BY emp_salary;  Last Name First Name SalaryLast Name First Name Salary--------------- --------------- -------------------------- --------------- -----------Markis Marcia $25,000.00Markis Marcia $25,000.00Amin Hyder $25,000.00Amin Hyder $25,000.00Prescott Sherri $25,000.00Prescott Sherri $25,000.00Bock Douglas $30,000.00Bock Douglas $30,000.00Joyner Suzanne $43,000.00Joyner Suzanne $43,000.00Zhu Waiman $43,000.00Zhu Waiman $43,000.006 rows selected.6 rows selected.

Page 12: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using IN OperatorUsing IN Operator

SELECT emp_last_name "Last Name", emp_first_name "First SELECT emp_last_name "Last Name", emp_first_name "First Name",Name", emp_city "City"emp_city "City"FROM employeeFROM employeeWHERE emp_city IN ('Marina', 'Edwardsville', 'St. Louis')WHERE emp_city IN ('Marina', 'Edwardsville', 'St. Louis')ORDER BY emp_city;ORDER BY emp_city;  Last Name First Name CityLast Name First Name City--------------- --------------- ---------------------------- --------------- -------------Bordoloi Bijoy EdwardsvilleBordoloi Bijoy EdwardsvillePrescott Sherri EdwardsvillePrescott Sherri EdwardsvilleJoyner Suzanne MarinaJoyner Suzanne MarinaAmin Hyder MarinaAmin Hyder MarinaZhu Waiman St. LouisZhu Waiman St. LouisBock Douglas St. LouisBock Douglas St. Louis

  

Page 13: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using the NOT IN OperatorUsing the NOT IN Operator

• NOT can precede IN to form negative.NOT can precede IN to form negative.• To get the list of employees who did not earn the To get the list of employees who did not earn the

three salary figures listed abovethree salary figures listed above

SELECT emp_last_name "Last Name", emp_first_name "First Name",SELECT emp_last_name "Last Name", emp_first_name "First Name", emp_salary "Salary"emp_salary "Salary"FROM employeeFROM employeeWHERE emp_salary NOT IN (43000, 30000, 25000)WHERE emp_salary NOT IN (43000, 30000, 25000)ORDER BY emp_salary;ORDER BY emp_salary;  Last Name First Name SalaryLast Name First Name Salary--------------- --------------- -------------------------- --------------- -----------Joshi Dinesh $38,000.00Joshi Dinesh $38,000.00Bordoloi Bijoy $55,000.00Bordoloi Bijoy $55,000.00  

Page 14: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

RANGES (BETWEEN AND NOT BETWEEN)RANGES (BETWEEN AND NOT BETWEEN)

• Oracle provides two operators, BETWEEN and Oracle provides two operators, BETWEEN and NOT BETWEEN that can simply the range of NOT BETWEEN that can simply the range of values in a query.values in a query.

• This eliminates the need to use a more complex This eliminates the need to use a more complex WHERE clause involving the use of the AND WHERE clause involving the use of the AND logical operator.logical operator.

Page 15: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using the BETWEEN OperatorUsing the BETWEEN Operator

• The following query uses the AND logical operator.The following query uses the AND logical operator.

SELECT emp_last_name "Last Name", emp_first_name "First Name",SELECT emp_last_name "Last Name", emp_first_name "First Name", emp_salary "Salary"emp_salary "Salary"FROM employeeFROM employeeWHERE emp_salary >= 25000 AND emp_salary <= 40000WHERE emp_salary >= 25000 AND emp_salary <= 40000ORDER BY emp_salary;ORDER BY emp_salary;

Last Name First Name SalaryLast Name First Name Salary-------------- --------------- ------------------------- --------------- -----------Markis Marcia $25,000.00Markis Marcia $25,000.00Amin Hyder $25,000.00Amin Hyder $25,000.00Prescott Sherri $25,000.00Prescott Sherri $25,000.00Bock Douglas $30,000.00Bock Douglas $30,000.00Joshi Dinesh $38,000.00Joshi Dinesh $38,000.00

Page 16: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using the BETWEEN OperatorUsing the BETWEEN Operator

• The query can be rewritten using the BETWEEN The query can be rewritten using the BETWEEN operator. operator.

SELECT emp_last_name "Last Name", emp_first_name "First Name",SELECT emp_last_name "Last Name", emp_first_name "First Name", emp_salary "Salary"emp_salary "Salary"FROM employee FROM employee WHERE emp_salary BETWEEN 25000 AND 40000WHERE emp_salary BETWEEN 25000 AND 40000ORDER BY emp_salary;ORDER BY emp_salary;Last Name First Name SalaryLast Name First Name Salary--------------- --------------- -------------------------- --------------- -----------Markis Marcia $25,000.00Markis Marcia $25,000.00Amin Hyder $25,000.00Amin Hyder $25,000.00Prescott Sherri $25,000.00Prescott Sherri $25,000.00Bock Douglas $30,000.00Bock Douglas $30,000.00Joshi Dinesh $38,000.00Joshi Dinesh $38,000.00

Page 17: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Using the NOT BETWEEN OperatorUsing the NOT BETWEEN Operator

SELECT emp_last_name "Last Name", emp_salary "Salary"SELECT emp_last_name "Last Name", emp_salary "Salary"

FROM employee FROM employee

WHERE emp_salary NOT BETWEEN 28000 AND 50000WHERE emp_salary NOT BETWEEN 28000 AND 50000

ORDER BY emp_salary;ORDER BY emp_salary;

Last Name SalaryLast Name Salary

--------------- -------------------------- -----------

Markis $25,000.00Markis $25,000.00

Amin $25,000.00Amin $25,000.00

Prescott $25,000.00Prescott $25,000.00

Bordoloi $55,000.00Bordoloi $55,000.00

Page 18: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

LIKE AND NOT LIKELIKE AND NOT LIKE

• The LIKE and NOT LIKE operators can be used to The LIKE and NOT LIKE operators can be used to search for data rows containing incomplete or partial search for data rows containing incomplete or partial character strings within a data column. character strings within a data column.

• The next query searches the employee table for The next query searches the employee table for employee names that begin with the characters 'Bo'.employee names that begin with the characters 'Bo'.

• The search is case-sensitive meaning that 'Bo' is not The search is case-sensitive meaning that 'Bo' is not equivalent to 'BO'.equivalent to 'BO'.

Page 19: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

LIKE AND NOT LIKELIKE AND NOT LIKE

SELECT emp_last_name "Last Name", emp_first_name "First SELECT emp_last_name "Last Name", emp_first_name "First Name"Name"

FROM employeeFROM employee

WHERE emp_last_name LIKE 'Bo%';WHERE emp_last_name LIKE 'Bo%';

Last Name First NameLast Name First Name

------------- -------------------------- -------------

Bordoloi BijoyBordoloi Bijoy

Bock DouglasBock Douglas

Page 20: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

LIKE AND NOT LIKELIKE AND NOT LIKE

Wild cardWild card MeaningMeaning

% % (percent)(percent)any string of zero or more charactersany string of zero or more characters

_ (underscore)_ (underscore) any single characterany single character

[ ] (brackets)[ ] (brackets) any single character within a specified range such as 'any single character within a specified range such as 'aa' ' to 'to 'dd', inclusive [a-d] or a set of characters such as ', inclusive [a-d] or a set of characters such as [aeiouy][aeiouy]

[^] (not brackets)[^] (not brackets) any single character any single character not not in the specified range or set. in the specified range or set. (e.g., [^a-f] )(e.g., [^a-f] )

Oracle supports only the Oracle supports only the first twofirst two, SQL-Server supports all four. , SQL-Server supports all four. SQL Server and Sybase supports all four.SQL Server and Sybase supports all four.

Page 21: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

MORE EXAMPLESMORE EXAMPLES

• LIKE '%inger' will search for every name that ends LIKE '%inger' will search for every name that ends with 'inger' (Rwith 'inger' (Ringeringer, Str, Stringeringer).).

• LIKE '%en%' will search for every name that has the LIKE '%en%' will search for every name that has the letters 'en' in the name (Bletters 'en' in the name (Benennet, Grenet, Greenen, McBadd, McBaddenen).).

• LIKE '_heryl' will search for every six-letter name LIKE '_heryl' will search for every six-letter name ending with 'heryl' (Cending with 'heryl' (Cherylheryl). Notice how this is ). Notice how this is different than '%heryl' which would return names that different than '%heryl' which would return names that are six characters or more.are six characters or more.

Page 22: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

MORE EXAMPLESMORE EXAMPLES

• LIKE '[CK]ars[eo]n' will search for every six-letter LIKE '[CK]ars[eo]n' will search for every six-letter name that begins with a 'C' or 'K' and has the letter 'e' name that begins with a 'C' or 'K' and has the letter 'e' or 'o' between 'ars' and 'n' (e.g., 'or 'o' between 'ars' and 'n' (e.g., 'CCarsarseen,' 'n,' 'KKarsarseen,' n,' ''CCarsarsoon,' and 'n,' and 'KKarsarsoon'.n'.

• LIKE '[M-Z]inger' will search for all the names LIKE '[M-Z]inger' will search for all the names ending with 'inger' that begin with any single letter ending with 'inger' that begin with any single letter 'M' thru 'Z' (R'M' thru 'Z' (Ringeringer).).

• LIKE 'M[^c]%' will search for all the names that LIKE 'M[^c]%' will search for all the names that begin with 'M' not having 'c' as the second letter.begin with 'M' not having 'c' as the second letter.

Page 23: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

MORE EXAMPLESMORE EXAMPLES

•The SELECT statement shown below generates a The SELECT statement shown below generates a result table that includes all DISTINCT rows where result table that includes all DISTINCT rows where the employee social security number in the the employee social security number in the assignmentassignment table ends with the numbers 555. table ends with the numbers 555.

SELECT DISTINCT work_emp_ssn "Emp SSN"SELECT DISTINCT work_emp_ssn "Emp SSN"

FROM assignmentFROM assignment

WHERE work_emp_ssn LIKE '%555';WHERE work_emp_ssn LIKE '%555';

Emp SSNEmp SSN

------------------------

999555555999555555

Page 24: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

UNKNOWN VALUESUNKNOWN VALUES (IS NULL AND IS NOT NULL) (IS NULL AND IS NOT NULL)

• NULL value is NULL value is not synonymous not synonymous with "zero" with "zero" (numerical values) or "blank" (character values).(numerical values) or "blank" (character values).

• NULL values allow users to distinguish between a NULL values allow users to distinguish between a deliberate entry of zero/blank and a non-entry of deliberate entry of zero/blank and a non-entry of data.data.

SELECT *SELECT *

FROM assignment FROM assignment

WHERE work_hours IS NULL;WHERE work_hours IS NULL;

WORK_EMP_ WORK_PRO_NUMBER WORK_HOURSWORK_EMP_ WORK_PRO_NUMBER WORK_HOURS

--------- --------------- ------------------- --------------- ----------

999444444 1999444444 1

999666666 20999666666 20

Page 25: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

MORE EXAMPLESMORE EXAMPLES

SELECT *SELECT *

FROM assignmentFROM assignment

WHERE work_hours = 0;WHERE work_hours = 0;

no rows selectedno rows selected

• The query did not return a result table because none The query did not return a result table because none of the rows in the assignment table have a zero of the rows in the assignment table have a zero value for work_hours. Thus, you can see that zero value for work_hours. Thus, you can see that zero (0) is a value, not an "unknown value." (0) is a value, not an "unknown value."

Page 26: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

MORE EXAMPLESMORE EXAMPLES

• The NOT NULL condition can also be tested.The NOT NULL condition can also be tested.

SELECT *SELECT *

FROM assignment FROM assignment

WHERE work_hours IS NOT NULL;WHERE work_hours IS NOT NULL;

15 rows selected.15 rows selected.

• The result table contains all the rows where The result table contains all the rows where work_hours column contains a value. work_hours column contains a value.

Page 27: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

EXPRESSIONS IN SELECT CLAUSESEXPRESSIONS IN SELECT CLAUSES

• An expression is formed by combining a column An expression is formed by combining a column name or constant with an arithmetic operator.name or constant with an arithmetic operator.

• The arithmetic operators used in SQL are The arithmetic operators used in SQL are

SYMBOL OPERATION ORDER

* Multiplication 1

/ Division 1

% Modulo 1

+ Addition 2

- Subtraction 2

Page 28: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

MORE EXAMPLESMORE EXAMPLES

SELECT emp_last_name "Last Name", emp_first_name "First SELECT emp_last_name "Last Name", emp_first_name "First Name", Name",

emp_salary/12 "Monthly Salary"emp_salary/12 "Monthly Salary"FROM employeeFROM employeeWHERE emp_salary/12 > 3500WHERE emp_salary/12 > 3500ORDER BY emp_last_name;ORDER BY emp_last_name;  Last Name First Name Monthly SalaryLast Name First Name Monthly Salary--------------- --------------- ----------------------------- --------------- --------------Bordoloi Bijoy $4,583.33Bordoloi Bijoy $4,583.33Joyner Suzanne $3,583.33Joyner Suzanne $3,583.33Zhu Waiman $3,583.33 Zhu Waiman $3,583.33 

Page 29: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

EXPRESSIONSEXPRESSIONS

• When expression is used in select with a column When expression is used in select with a column name it has no effect on the table’s underlying name it has no effect on the table’s underlying values.values.

• The data contained in each column must be The data contained in each column must be defined as int, smallint, tinyint, float, money, and defined as int, smallint, tinyint, float, money, and smallmoney.smallmoney.

• The result of an arithmetic operation on NULL is The result of an arithmetic operation on NULL is NULL. NULL.

Page 30: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Examples of Operations on NullsExamples of Operations on Nulls Table: CompensationTable: Compensation

EMP#EMP# JOBCODEJOBCODE SALARY SALARY COMMISSIONCOMMISSION

E10E10 SALES SALES 12500 12500 32090 32090

E11E11 NULL NULL 25000 25000 8000 8000

E12E12 SALES SALES 44000 44000 0 0

E13E13 SALES SALES 44000 44000 NULL NULL

E14E14 PROG PROG 19500 19500 NULL NULL

E15E15 CLERK CLERK NULL NULL NULL NULL

Page 31: Bordoloi and Bock Chapter 4 : Adding Power to Queries

Bordoloi and BockBordoloi and Bock

Examples of Operations on NullsExamples of Operations on NullsList the employees whose total earnings exceed $30000.00.List the employees whose total earnings exceed $30000.00.

SELECTSELECT EMP#EMP#FROMFROM COMPENSATIONCOMPENSATIONWHEREWHERE JOBCODE = “SALES” JOBCODE = “SALES” AND AND (SALARY + COMMISSION) > 30000(SALARY + COMMISSION) > 30000

EMP#EMP#E10E10E12E12

E13 is missing because?E13 is missing because?