Filtering Data Flashcards
What is returned if you only specify a date you want to filter for from a column but the column is DATETIME type?
When you only specify a date when filtering a DATETIME column, time of midnight is assumed. So, if asked for ‘20070212’, only records on that date with a time stamp of midnight would be returned.
SQL Server 70-461 03-01
How does the NOT operator treat nulls?
Nulls will be excluded unless IS NULL, IS NOT NULL or some similar expression is used.
For example, NOT region=’WA’ will only return rows where the region is filled in and doesn’t equal WA. Since a null has an unknown value, the query cannot decide if it doesn’t equal WA and excludes it.
SQL Server 70-461 03-01
What is the proper form of a predicate using LIKE?
column LIKE pattern
SQL Server 70-461 03-01
How can you combine predicates in the WHERE clause?
- AND
- OR
SQL Server 70-461 03-01
Explain Three Valued Logic
Predicate can evaluate to true, false or unknown since NULLS are involved.
SQL Server 70-461 03-01
Explain Two-Valued Logic
Predicate expression evaluates to true or false, if NULLS are not possible.
SQL Server 70-461 03-01
How does the % wildcard work?
- The percent sign stands for a string of any size, including an empty string.
- Example: ‘D%’ This will find all strings that start with a D and follow with pretty much anything else
SQL Server 70-461 03-01
How does the _ wildcard work?
- The _ stands for any one character.
- Example: So, if you wanted to find a name that started with any character but wanted to ensure the second character was D you would use ‘_D%’. % standing for a string of any number of characters, even an empty string.
SQL Server 70-461 03-01
How does the character list wildcard work?
- Between square brackets, [ ], list the acceptable characters.
- Example: ‘[ABC]%’ This will return all names that start with A, B or C and have anything after that.
SQL Server 70-461 03-01
What form does a predicate need to be in for the query to filter efficiently?
A search argument
SQL Server 70-461 03-01
What does not work when trying to include NULLS in a WHERE clause?
- Region=NULL
- Two nulls are not considered equal to each other since null is an unknown value.
- Region <>’WA’ will not work either because it will not include regions that are NULL.
SQL Server 70-461 03-01
What does it mean for a WHERE clause to evaluate to false?
The predicate evaluates to false and nulls are not included.
SQL Server 70-461 03-01
How does the character range wildcard work?
- Between square brackets, [ ], indicate a range of letters or numbers. Examples, [A-E] or [0-9].
- Example: ‘[A-E]%’ would indicate that the first letter of the name start with A, B, C, D or E and have anything after that.
SQL Server 70-461 03-01
How does the NOT IN character list or range wild card work?
It works just like the character list and character range wildcards except you put a ^ after the left bracket to indicate not in the list or range.
SQL Server 70-461 03-01
What is a predicate?
An expression that is either true or false.
SQL Server 70-461 03-01