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
2004 Longitudinal Study Technical Report California Regional Occupational Centers & Programs (ROCP) Douglas E. Mitchell Website.
Advertisements

KnowHow2Go Financial Aid Night © 2007 Hispanic Scholarship Fund WELCOME TO FINANCIAL AID NIGHT.
Modeling Logic with Decision Tables and Trees. 2 Decision Trees and Decision Tables Often our problem solutions require decisions to be made according.
PL/SQL.
Work with Data and Decision Structure. Murach’s Java SE 6, C3© 2007, Mike Murach & Associates, Inc. Slide 2.
Normalization ISYS 464. Database Design Based on ERD Strong entity: Create a table that includes all simple attributes –Composite Weak entity: add owner.
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.
Data Analysis Statistics. Inferential statistics.
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.
SQLPlus Commands. Oracle Account Server: libra.sfsu.edu Telnet: libra.sfsu.edu How to use Oracle: –
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 MS Access. Creating a New Database File/New –Blank database –New database name and location.
Structured Query Language Review ISYS 650. Language Overview Three major components: –Data definition language, DDL Create, Drop and Alter Tables or Views.
Nested IF and Complex Condition. Nested IF Example: –Rules to determine bonus: JobCode = 1, Bonus=500 JobCode = 2, Bonus = 700 JobCode = 3, Bonus = 1000.
Introduction to Structured Query Language, SQL. SQL Select Command SELECT * FROM tableName WHERE criteria;
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.
Complex Conditions. Logical Operators: AND, OR, NOT AND Cond1Cond2Cond1 AND Cond2T TF FTF OR Cond1Cond2Cond1 OR Cond2T TF FTF NOT CondNOT Cond T F.
Introduction to Database ISYS 263. File Concepts File consists of a group of records. Each record contains a group of fields. –Key field, grouping field,
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.
Data Analysis Statistics. Inferential statistics.
Querying Database. Basic Query Language Operations Selection Projection Join Aggregates: Max, Min, Sum, Avg, Count –Totals and SubTotals –GroupBy Calculated.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
VB.Net Decisions. The If … Then Statement If condition Then Statements End If If condition Then Statements Else Statements End If Condition: –Simple condition:
Relational Operators, SQL, and Access Query ISYS 562.
© Scott/Jones Publishing, Inc. 1 Chapter 19 Advanced Features of List Management Excel 2003, Volume 2 by Karen J. Jolly.
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.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
© Scott/Jones Publishing, Inc. 1 Chapter 18 Working with Advanced Functions Excel 2003, Volume 2 by Karen J. Jolly Scott/Jones Publishing, Inc.
Introduction to MS Access. Creating a New Database File/New –Blank database –New database name and location.
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.
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.
FORM VALIDATION (Java Script ). Required Fields A required field in a form is a field that MUST have at least some content before the form will be processed.
SQL Miscellaneous Topics. Views A database view is: – a virtual or logical table based on a query. – a stored query. CREATE VIEW viewname AS query; –CREATE.
Introduction to Access ISYS 363. Access Objects Tables –Open a table: Double click the table name –Home/View: Datasheet view Design view Queries Forms.
Solving Equations Using Logs. True or False? 1.Log 4 = log Log 15 = log 3 x log 5 3.Log 4 = log 8 – log 2 4.Log 64 = 2 log 8 5.Log 64 = 8 log 2.
Set Operators. Union Intersect Difference Cartesian product.
Faculty Demographics Faculty Demographics Table 8 Faculty Demographics Prof. Ed. Faculty in Initial Teacher Preparation Programs*
Decision Structure - 2 ISYS 350.
Module Example: Influence of Race and Gender on Income1
Using Advanced Functions and Conditional Formatting
Decision Structure ISYS 350.
Introduction to Database
Comparison Operators Relational Operators.
Introduction to Database
File Processing with Excel’s List
Decision Structure - 2 ISYS 350.
PCORnet Modular Program 1
Population pyramids Age - Sex Graphs.
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.
Decision Structure - 2 ISYS 350.
Database Normalization.
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)

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 applicants 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? – AND has higher priority

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 this complex condition correct? – GPA >= 3.2 AND Major = Acct OR Major = CIS – Try: A CIS student with GPA=2.0 Need parenthesis, ( ) – GPA >= 3.2 AND (Major = Acct OR Major = CIS )

Order of Evaluation 1. () 2. And 3. Or

Entering Complex Condition StudentTable: SID, Sname, Major, Sex, FID, GPA Major = CIS and Sex=F Major = CIS OR Sex=F Major=CIS AND GPA>2.5 OR Major=Acct AND GPA>2.7 GPA>2.5 OR Major=CIS AND Sex=F (GPA>2.5 OR Major=CIS) AND Sex=F (Major=CIS AND GPA>3.0 OR Major=Acct) AND Sex=F

Entering Complex Condition Customer Table: CID, Cname, City, Rating Rating=A AND City=SF Rating=A OR City=SF Rating = A OR Rating = B AND City=SF

Employee Table: EmpID, EMpName, Sex, Race, BirthDate, HireDate, Salary, Dept (Sex = Female OR Dept=A) AND Race = Hispanic (Sex = Male OR Sex=male OR Salary>50000) AND Race = Asian (Sex = Male OR Sex=male AND Salary>50000) AND Race = Asian Sex = Female Or Sex=male AND Race = Hispanic OR Dept = A

Excels Advanced Filter Data/Filter/Advanced Filter – List range – Criteria range

Excels 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

Excels IF with Complex Condition Event admission fee: – If 12<=Age<=65 Fee=20 – Otherwise, free Rules to calculate employee bonus are: – If JobCode = 1 AND Salary < 5000 Bonus = 10% * Salary – Otherwise: Bonus = 8% * Salary