tailieunhanh - Subqueries full

After completing this lesson, you should be able to do the following: Describe the types of problem that subqueries can solve Define subqueries List the types of subqueries Write single-row and multiple-row subqueries | Subqueries Schedule: Timing Topic 25 minutes Lecture 30 minutes Practice 55 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the types of problem that subqueries can solve Define subqueries List the types of subqueries Write single-row and multiple-row subqueries Lesson Aim In this lesson, you learn about more advanced features of the SELECT statement. You can write subqueries in the WHERE clause of another SQL statement to obtain values based on an unknown conditional value. This lesson covers single-row subqueries and multiple-row subqueries. Using a Subquery to Solve a Problem Who has a salary greater than Abel’s? Which employees have salaries greater than Abel’s salary? Main Query: ? What is Abel’s salary? ? Subquery Using a Subquery to Solve a Problem Suppose you want to write a query to find out who earns a salary greater than Abel’s salary. To solve this problem, you need two queries: one to find what Abel earns, and a second query to find who earns more than that amount. You can solve this problem by combining the two queries, placing one query inside the other query. The inner query or the subquery returns a value that is used by the outer query or the main query. Using a subquery is equivalent to performing two sequential queries and using the result of the first query as the search value in the second query. Instructor Note This lesson concentrates on noncorrelated subqueries. Subquery Syntax The subquery (inner query) executes once before the main query. The result of the subquery is used by the main query (outer query). SELECT select_list FROM table WHERE expr operator (SELECT select_list FROM table); Subqueries A subquery is a SELECT statement that is embedded in a clause of another SELECT statement. You can build powerful statements out of simple ones by using subqueries. They can be very useful when you need to select rows from a table with a condition that depends on the data in the table . | Subqueries Schedule: Timing Topic 25 minutes Lecture 30 minutes Practice 55 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the types of problem that subqueries can solve Define subqueries List the types of subqueries Write single-row and multiple-row subqueries Lesson Aim In this lesson, you learn about more advanced features of the SELECT statement. You can write subqueries in the WHERE clause of another SQL statement to obtain values based on an unknown conditional value. This lesson covers single-row subqueries and multiple-row subqueries. Using a Subquery to Solve a Problem Who has a salary greater than Abel’s? Which employees have salaries greater than Abel’s salary? Main Query: ? What is Abel’s salary? ? Subquery Using a Subquery to Solve a Problem Suppose you want to write a query to find out who earns a salary greater than Abel’s salary. To solve this problem, you need two queries: one to find what Abel earns, and a .

TÀI LIỆU LIÊN QUAN
TỪ KHÓA LIÊN QUAN