About: Correlated subquery   Goto Sponge  NotDistinct  Permalink

An Entity of Type : owl:Thing, within Data Space : wasabi.inria.fr associated with source document(s)

In a SQL database query, a correlated subquery (also known as a synchronized subquery) is a subquery (a query nested inside another query) that uses values from the outer query. Because the subquery may be evaluated once for each row processed by the outer query, it can be slow. Here is an example for a typical correlated subquery. In this example, the objective is to find all employees whose salary is above average for their department. SELECT employee_number, name FROM employees emp WHERE salary > ( SELECT AVG(salary) FROM employees WHERE department = emp.department);

AttributesValues
label
  • Correlated subquery
  • Корельований підзапит
comment
  • У запитах до баз даних SQL, корельований підзапит (також відомий як синхронізований підзапит) — це підзапит (запит, вкладений усередині іншого запиту), який використовує значення з зовнішнього запиту. Оскільки підзапит може бути обчислено один раз для кожного рядка, обробленого зовнішнім запитом, він може бути неефективним. Нижче наведено приклад типового корельованого підзапиту. Метою даного прикладу є знайти всіх співробітників, заробітна платня яких вища за середню в їхньому відділі. У наведеному вище прикладі зовнішнім запитом є а внутрішнім запитом (корельованим підзапитом) є
  • In a SQL database query, a correlated subquery (also known as a synchronized subquery) is a subquery (a query nested inside another query) that uses values from the outer query. Because the subquery may be evaluated once for each row processed by the outer query, it can be slow. Here is an example for a typical correlated subquery. In this example, the objective is to find all employees whose salary is above average for their department. SELECT employee_number, name FROM employees emp WHERE salary > ( SELECT AVG(salary) FROM employees WHERE department = emp.department);
sameAs
topic
described by
subject
dbo:wikiPageID
Wikipage revision ID
dbo:wikiPageWikiLink
Link from a Wikipage to an external page
is primary topic of
wasDerivedFrom
http://purl.org/li...ics/gold/hypernym
dbo:abstract
  • У запитах до баз даних SQL, корельований підзапит (також відомий як синхронізований підзапит) — це підзапит (запит, вкладений усередині іншого запиту), який використовує значення з зовнішнього запиту. Оскільки підзапит може бути обчислено один раз для кожного рядка, обробленого зовнішнім запитом, він може бути неефективним. Нижче наведено приклад типового корельованого підзапиту. Метою даного прикладу є знайти всіх співробітників, заробітна платня яких вища за середню в їхньому відділі. SELECT employee_number, nameFROM employees AS empWHERE salary > (SELECT AVG(salary) FROM employees WHERE department = emp.department); У наведеному вище прикладі зовнішнім запитом є SELECT employee_number, nameFROM employees AS empWHERE salary > ... а внутрішнім запитом (корельованим підзапитом) є SELECT AVG(salary)FROM employeesWHERE department = emp.department У наведеному вище вкладеному запиті внутрішній запит повинен виконуватися повторно для кожного працівника (досить розумна реалізація може результат внутрішнього запиту на основі відділ-по-відділу, але навіть у найкращому випадку внутрішній запит повинен виконуватися один раз для кожного відділу). Корельовані підзапити можуть з'являтися не тільки в операторі WHERE; наприклад, такий запит використовує корельований підзапит в операторі SELECT, щоб надрукувати весь список співробітників разом із середньою заробітною платнею для кожного відділу. Знову ж таки, оскільки підзапит корелюється з колонкою зовнішнього запиту, він повинен повторно виконатися для кожного рядка результату. SELECT employee_number, name, (SELECT AVG(salary) FROM employees WHERE department = emp.department) AS department_averageFROM employees AS emp;
  • In a SQL database query, a correlated subquery (also known as a synchronized subquery) is a subquery (a query nested inside another query) that uses values from the outer query. Because the subquery may be evaluated once for each row processed by the outer query, it can be slow. Here is an example for a typical correlated subquery. In this example, the objective is to find all employees whose salary is above average for their department. SELECT employee_number, name FROM employees emp WHERE salary > ( SELECT AVG(salary) FROM employees WHERE department = emp.department); In the above query the outer query is SELECT employee_number, name FROM employees emp WHERE salary > ... and the inner query (the correlated subquery) is SELECT AVG(salary) FROM employees WHERE department = emp.department In the above nested query the inner query has to be re-executed for each employee. (A sufficiently smart implementation may cache the inner query's result on a department-by-department basis, but even in the best case the inner query must be executed once per department.) Correlated subqueries may appear elsewhere besides the WHERE clause; for example, this query uses a correlated subquery in the SELECT clause to print the entire list of employees alongside the average salary for each employee's department. Again, because the subquery is correlated with a column of the outer query, it must be re-executed for each row of the result. SELECT employee_number, name, (SELECT AVG(salary) FROM employees WHERE department = emp.department) AS department_average FROM employees emp
dbo:wikiPageLength
dbp:wikiPageUsesTemplate
is sameAs of
is topic of
is dbo:wikiPageWikiLink of
is topic of
is http://vocab.deri.ie/void#inDataset of
Faceted Search & Find service v1.13.91 as of Mar 24 2020


Alternative Linked Data Documents: Sponger | ODE     Content Formats:       RDF       ODATA       Microdata      About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data]
OpenLink Virtuoso version 07.20.3229 as of Jul 10 2020, on Linux (x86_64-pc-linux-gnu), Single-Server Edition (94 GB total memory)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2025 OpenLink Software