0% found this document useful (0 votes)
57 views2 pages

Lab 4 SP 5

1. The key differences between correlated and non-correlated subqueries are that correlated subqueries compare values across multiple columns simultaneously, while non-correlated subqueries do not. 2. The two examples of subqueries involving multiple columns are not identical - the first performs the subquery in the WHERE clause and then compares, while the second compares and only if not in 174 does the subquery in the WHERE clause. 3. An inline view defines a particular data source for the outer SELECT statement, where a subquery in the FROM clause of a SELECT statement is called an inline view.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

Lab 4 SP 5

1. The key differences between correlated and non-correlated subqueries are that correlated subqueries compare values across multiple columns simultaneously, while non-correlated subqueries do not. 2. The two examples of subqueries involving multiple columns are not identical - the first performs the subquery in the WHERE clause and then compares, while the second compares and only if not in 174 does the subquery in the WHERE clause. 3. An inline view defines a particular data source for the outer SELECT statement, where a subquery in the FROM clause of a SELECT statement is called an inline view.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Care este diferenta dintre subinterogarile clasice si cele corelate?

Subinterogarile colerate compara simultan valorile mai multor coloane, iar


cele clasice nu.

2.Studiati cele doua exemple de la sectiunea"Subinterogari care implica mai multe


coloane" si aratati care este succesiunea si logica de executie. Sunt identice sau
nu?
Aceste doua subinterogari nu sunt identice.
Succesiunea logica este urmatoarea:la prima se face prima data subinterogarea
din WHERE si apoi se compara iar la a
doua se face tot in WHERE apoi se compara si daca nu este din 174.

3.Ce este o vedere inline?


Vedere inline defineste o sursa de date particulara pentru fraza SELECT
principala.
O subinterogare dintr-o clauza FROM a unei interogari SELECT, poarta numele
de vedere inline.

4. Care este utilitatea clauzeii WITH?


Este utila in cazul in care o interogare se refera de mai multe ori la
acelasi bloc, si cand contine
jonctiuni si agregari.

1.
SELECT employee_id, manager_id, department_id
FROM employees
WHERE (manager_id, department_id) IN
(SELECT manager_id, department_id
FROM employees
WHERE employee_id IN (178,174))
AND employee_id NOT IN (178,174);

EMPLOYEE_ID MANAGER_ID DEPARTMENT_ID


175 149 80
176 149 80
179 149 80
177 149 80

2. SELECT employee_id, manager_id, department_id


FROM employees
WHERE manager_id IN
(SELECT manager_id
FROM employees
WHERE employee_id IN (178,174))
AND department_id IN
(SELECT department_id
FROM employees
WHERE employee_id IN (178,174))

3. SELECT last_name, department_id, salary


FROM employees
WHERE (department_id, salary) IN
(select department_id, salary
FROM employees
WHERE commission_pct IS NOT NULL);

4. SELECT last_name, e.department_name, salary, d.location_id


FROM employees e
INNER JOIN departments d on d.department_id = e.department_id
WHERE (salary, commission_pct) IN
(SELECT salary, commission_pct
FROM employees e, departments d

5. SELECT first_name, last_name, hire_date, salary


FROM employees e
WHERE (salary, NVL(0,commission_pct)) IN
(SELECT salary, NVL(0,commission_pct)
FROM employees e
WHERE last_name like 'Kochhar');

6. SELECT a.last_name, a.salary, a.department_id,b.salavg


FROM employees a,
(SELECT department_id, AVG(salary) salavg
FROM employees
GROUP BY department_id)b
WHERE a.department_id=b.department_id and salary>b.salavg;

You might also like