Complex Conditions. Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F.

Slides:



Advertisements
Similar presentations
Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
Advertisements

Complex Conditions. Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F.
Work with Data and Decision Structure. Murach’s Java SE 6, C3© 2007, Mike Murach & Associates, Inc. Slide 2.
MONTEGO BAY HIGH SCHOOL INFORMATION TECHNOLOGY THE EXCEL IF FUNCTION.
SQL Sub (or Nested ) Query. Examples Q: Find students whose GPA is below the average. –The criteria itself requires a SQL statement. –SELECT * FROM student.
Tutorial 7: Using Advanced Functions and Conditional Formatting
Data Modeling and Relational Database Design ISYS 650.
Querying Database ISYS 363. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy.
Introduction to Database ISYS 363. File Concepts File consists of a group of records. Each record contains a group of fields. Example: Student file –SIDSnameMajorSexGPA.
Nested IF and Complex Condition. Nested IF Example: –Rules to determine bonus: JobCode = 1, Bonus=500 JobCode = 2, Bonus = 700 JobCode = 3, Bonus = 1000.
VB.Net Introduction - 2. Counter Example: Keep track the number of times a user clicks a button Need to declare a variable: Dim Counter As Integer Need.
IF Function Decision: Action based on condition. Examples SF State Tuition calculation: –
1 Selection in C. 2 If / else if statement:  The else part of an if statement can be another if statement. if (condition) … else if (condition) … else.
Introduction to Database ISYS 363. File Concepts File consists of a group of records. Each record contains a group of fields. Example: Student file –SIDSnameMajorSexGPA.
Introduction to Database. File Formats Comma delimited file –"s1","peter",3 –"s2","paul",2.5 –"s3","mary",3.5 –Demo: Excel – Data/Import Extended Markup.
Basic SQL Select Commands. Basic Relational Query Operations Selection Projection Natural Join Sorting Aggregation: Max, Min, Sum, Count, Avg –Total –Sub.
Querying Database ISYS 363. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy.
Introduction to Access BUS 782. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
Querying Database. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy Calculated.
VB.Net Decisions. The If … Then Statement If condition Then Statements End If If condition Then Statements Else Statements End If Condition: –Simple condition:
Selection in C.
Tutorial 8: Working with Advanced Functions
Work with Data and Decision Structure. Slide 2 Note: String and Date are classes.
COMPREHENSIVE Excel Tutorial 7 Using Advanced Functions, Conditional Formatting, and Filtering.
CENTURY 21 ACCOUNTING © Thomson/South-Western LESSON 3-1 Completing Payroll Records for Employee Earnings and Deductions.
Advanced SQL for Decision Support ISYS 650. Set Operators Union Intersect Difference Cartesian product.
© Scott/Jones Publishing, Inc. 1 Chapter 18 Working with Advanced Functions Excel 2003, Volume 2 by Karen J. Jolly Scott/Jones Publishing, Inc.
Decision Structure - 1 ISYS 350. Decision: Action based on condition Examples Simple condition: – If total sales exceeds $300 then applies 5% discount;
Decision Structure - 2 ISYS 350. Complex Condition with Logical Operators The logical AND operator (&&) and the logical OR operator (||) allow you to.
Expression and Decision Structure ISYS 350. Performing Calculations Basic calculations such as arithmetic calculation can be performed by math operators.
Introduction to Access ISYS 363. Creating a New Database MS Office button/New –Blank database –New database name and location.
BACS 287 Programming Logic 2. BACS 287 Sequence Construct The sequence construct is the default execution mode for the CPU. The instructions are executed.
Decision Structure - 2 ISYS 350. Complex Condition with Logical Operators The logical AND operator (&&) and the logical OR operator (||) allow you to.
Chapter 8 Database Redesign We only discuss complex sub-queries.
Relational Query Operators (Algebra). Relational Query Operators Set operations: Union, intersection, difference, Cartesian product Relational operations:
Querying Database ISYS 363.
Introduction to Query Language and SQL. Basic Query Language Operators Selection Projection Join Aggregates –Sum, Count, Max, Min, Avg SubTotal Calculated.
Decisions Action based on condition. Examples Simple condition: –If total sales exceeds $300 then applies 5% discount; otherwise, no discount. More than.
Introduction to Access BUS 782. Creating a New Database MS Office button/New –Blank database –New database name and location.
Introduction to Access ISYS 363. Access Objects Tables –Open –Design –New –Wizard Queries Forms Reports Pages.
Introduction to Access ISYS 363. Access Objects Tables –Open a table: Double click the table name –Home/View: Datasheet view Design view Queries Forms.
XP Life Insurance Premium Flowchart 1 Add Life Ins = “Y” Salary * Premium Rate Yes 0 No.
Set Operators. Union Intersect Difference Cartesian product.
Decision Structure - 1 ISYS 350. Decision: Action based on condition Examples Simple condition: – If total sales exceeds $300 then applies 5% discount;
Functions BUS 782. What are functions? Functions are prewritten formulas. We use functions to perform calculations. Enclose arguments within parentheses.
IF Function Decision: Action based on condition. Examples SF State Tuition calculation: –
CIS300 Test 3 Review Reinhardt. © 2009 Dale McIntosh. All Rights Reserved. Slides are Available at: uter/cistestreviews.html.
Decision Structure - 2 ISYS 350.
Using Advanced Functions and Conditional Formatting
Decision Structure ISYS 350.
Decision Structure - 1 ISYS 350.
Introduction to Database
Comparison Operators Relational Operators.
Introduction to Database
File Processing with Excel’s List
Decision Structure - 2 ISYS 350.
Querying Database ISYS 363.
Decision Structure - 2 ISYS 350.
Decision Structure - 2 ISYS 350.
File Processing with Excel’s List
Decision Structure - 2 ISYS 350.
Comparing Strings Strings can be compared using the == and != operators String comparisons are case sensitive Strings can be compared using >, =, and.
Decision Structure - 1 ISYS 350.
Decision: Action based on condition
Decision Structure - 2 ISYS 350.
Functions BUS 782.
Decision Structure - 1 ISYS 350.
Enrollment Management Update
Introduction to Database
Presentation transcript:

Complex Conditions

Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F

Examples Write a complex condition for: 12 <= Age <= 65 Use a complex condition to describe age not between 12 and 65. X <= 15 is equivalent to: X<15 AND X =15? (T/F) This complex condition is always false: – X 10 This complex condition is always true: – X >= 5 OR X <= 10

More Complex Conditions University admission rules: Applicants will be admitted if meet one of the following rules: – 1. Income >= 100,000 – 2. GPA > 2.5 AND SAT > 900 An applicant’s Income is 150,000, GPA is 2.9 and SAT is 800. Admitted? – Income >= 100,000 OR GPA > 2.5 AND SAT >900 How to evaluate this complex condition?

Scholarship: Business students with GPA at least 3.2 and major in Accounting or CIS qualified to apply: – 1. GPA >= 3.2 – 2. Major in Accounting OR CIS Is a CIS student with GPA = 2.0 qualified? – GPA >= 3.2 AND Major = “Acct” OR Major = “CIS” Is this complex condition correct?

NOT Set 1: Young: Age < 30 Set 2: Rich: Income >= 100,000 YoungRich

Order of Evaluation 1. () 2. Not 3. AND 4. OR

Entering Complex Condition Customer Table: CID, Cname, City, Rating Rating=“A” AND City=“SF” Rating=“A” OR City=“SF” Rating = “A” OR Rating = “B” Cname = “Chao” OR Cname = “Smith” Cname=“Chao” OR Rating=“A” OR City=“SF” Rating = “A” OR Rating = “B” AND City=“SF” (Rating = “A” OR Rating = “B”) AND City=“SF”

Entering Complex Condition Student table: SID, Sname, Major, GPA, Sex, FID Major=“CIS” OR GPA>3.0 AND Sex=“F” Major=“CIS” AND GPA>3.0 OR Sex=“F” (Major=“CIS” AND GPA>3.0 OR Major=“Acct”) AND Sex=“F” (Major=“CIS” AND GPA>3.0 OR Major=“Acct” AND GPA>2.5) AND Sex=“F”

Excel’s Advanced Filter Data/Filter/Advanced Filter – List range – Criteria range

Excel’s AND Function/OR Function =AND (cond1, cond2, …, cond n) – Up to 30 conditions – True if all conditions are true – False if any condition is false =OR (cond1, cond2, …, cond n) – True if any condition is true – False if all conditions are false

Excel’s IF with Complex Condition Rules to calculate employee bonus are: – If JobCode = 1 AND Salary < 5000 Bonus = 10% * Salary – Otherwise: Bonus = 8% * Salary Rules to calculate employee bonus are: – If JobCode = 1 AND Salary < 5000 OR Sex = “F” Bonus = 10% * Salary – Otherwise: Bonus = 8% * Salary