I.
Test your knowledge:
1.The following SELECT statement executes successfully:
SELECT last_name, job_id, salary AS Sal FROM employees;
TRUE
2. The following SELECT statement executes successfully:
SELECT *FROM job_grades;
FALSE
3. There are four coding errors in the following statement. Can you identify them?
SELECT employee_id, last_namesal x 12 ANNUAL SALARY FROM employees;
SELECT employee_id, last_name, (salary * 12) "ANNUAL SALARY"
FROM hr.employees;
4. Create a select statement that will display the last_name, First_name of employees under
department IT_Prog.
SELECT last_name, First_name “ IT_Prog” FROM hr.employees;
II. Research Work.
WHERE clause
The WHERE clause is used to filter records. It is used to extract only those records that
fulfill a specified condition.
Condition
A condition specifies a combination of one or more expressions and logical (Boolean)
operators and returns a value of TRUE , FALSE , or unknown.
Comparison Conditions
A comparison (or relational) operator is a mathematical symbol which is used to compare
two values. Comparison operators are used in conditions that compares one expression
with another.
Between Condition
The BETWEEN operator selects values within a given range. The values can be numbers,
text, or dates. The BETWEEN operator is inclusive: begin and end values are included.
In Condition
IN condition is an alternative to multiple OR conditions in SELECT, INSERT, UPDATE,
or DELETE statement. The IN operator allows multiple values to be tested against the
expression and thus reduces the use of multiple OR conditions with each test value.
Like Condition
The SQL LIKE condition allows you to use wildcards to perform pattern matching in a
query. The LIKE condition is used in the WHERE clause of a SELECT, INSERT,
UPDATE, or DELETE statement.
Logical Condition
A logical condition combines the results of two component conditions to produce a single
result based on them or to invert the result of a single condition.
Describe
DESCRIBE means to show the information in detail. Since we have several tables in our
SQL Server database, we will need a command to show a table's structure, such as
column names, data types, constraints on column names, etc.