Find all the information at the latest recruits
Problem-solving steps:
Title: query all the information at the latest recruits
goal: All information query employee
screening criteria: the latest entry
answer:
. 1 the SELECT 2 * - Search Information on the use of * . 3 the FROM . 4 the Employees . 5 the WHERE . 6 hire_date = ( - here a subquery, and hire_date as to match, so only one value, the max function usage rule attention . 7 the SELECT . 8 MAX (the hire_date) . 9 the FROM 10 the Employees . 11 )
Find recruits ranked third time information of all employees
Problem-solving steps:
Topic: Finding recruits staff time ranked third all information
Goal: All employees of the information inquiry
filter criteria: the third entry time to
answer:
. 1 the SELECT 2 * - All information with * easy . 3 the FROM . 4 the Employees . 5 WHERE hire_date = ( the SELECT the DISTINCT - subqueries noted hire_date is a value, a return value must be a subquery . 6 hire_date . 7 the FROM . 8 the Employees . 9 the ORDER BY - there is a small tips, descending row, taken from the third, to a 10 the hire_date DESC . 11 limit 2 ,. 1 - page syntax take a closer look, limit m, n => take starts from m + 1, take the n 12 )
Find all sectors of the current (to_date = '9999-01-01') leading the current salary details, and their corresponding department number dept_no
Problem-solving steps:
Title: Find (to_date = '9999-01-01') leading the current salary details of the various departments and their counterparts in the current number dept_no
target: query leadership salary details, the corresponding department number
Filters: Department table of the current time, hidden conditions (salary table current time)
answer:
1 the SELECT 2 S. * , 3 d.dept_no 4 the FROM 5 salaries S - Leftist to the department table, salary table full of people, so the table is better to call the shots, the situation will not be associated with an empty 6 LEFT JOIN dept_manager d ON S .emp_no = d.emp_no . 7 the WHERE . 8 s.TO_DATE = ' 9999-01-01 ' - filters . 9 the AND d.TO_DATE = ' 9999-01-01 '