Oracle sucks — различия между версиями

Материал из YourcmcWiki
Перейти к: навигация, поиск
м (Новая страница: «<pre>SELECT "alias6".birth_date AS "col4", "alias6".e_category AS "col5", "alias6".id_chief AS "col6", "alias6".id_department AS "col7", "alias6".fire_date AS "col8"...»)
 
м
 
(не показаны 2 промежуточные версии этого же участника)
Строка 1: Строка 1:
<pre>SELECT
+
Oracle, бывает, очень прикольно исполняет некоторые запросы.
"alias6".birth_date AS "col4",
+
 
"alias6".e_category AS "col5",
+
Например, здесь, если раскомментировать /* ORDER BY "alias1".id_employee */, результат запроса меняется!
"alias6".id_chief AS "col6",
+
 
"alias6".id_department AS "col7",
+
<source lang="sql">
"alias6".fire_date AS "col8",
+
"alias6".first_name AS "col9",
+
"alias6".hire_date AS "col10",
+
"alias6".id_employee AS "col11",
+
"alias6".last_name AS "col12",
+
"alias6".dtm_modified AS "col13",
+
"alias6".salary AS "col14",
+
"alias6".e_sex AS "col15",
+
"alias6".id_product AS "col16"
+
FROM
+
(
+
 
SELECT
 
SELECT
"alias1".id_employee as "col123",
+
"alias6".birth_date AS "col4",
CASE WHEN (EXISTS
+
"alias6".e_category AS "col5",
(
+
"alias6".id_chief AS "col6",
SELECT
+
"alias6".id_department AS "col7",
'1' AS "col1"
+
"alias6".fire_date AS "col8",
FROM
+
"alias6".first_name AS "col9",
t_employee "alias2"
+
"alias6".hire_date AS "col10",
WHERE
+
"alias6".id_employee AS "col11",
"alias2".id_chief = "alias1".id_employee
+
"alias6".last_name AS "col12",
)
+
"alias6".dtm_modified AS "col13",
) THEN ("alias1".id_employee) ELSE ("alias1".id_chief) END AS "col2"
+
"alias6".salary AS "col14",
FROM
+
"alias6".e_sex AS "col15",
t_employee "alias1"
+
"alias6".id_product AS "col16"
/* ORDER BY
+
FROM (
"alias1".id_employee */
+
SELECT "alias1".id_employee as "col123",
 +
  CASE WHEN (EXISTS (
 +
    SELECT '1' AS "col1"
 +
    FROM t_employee "alias2"
 +
    WHERE "alias2".id_chief = "alias1".id_employee
 +
  ))
 +
  THEN ("alias1".id_employee) ELSE ("alias1".id_chief) END AS "col2"
 +
FROM t_employee "alias1"
 +
/* ORDER BY "alias1".id_employee - если раскомментировать, результат запроса меняется! */
 
) "alias4"
 
) "alias4"
LEFT JOIN
+
LEFT JOIN (t_employee "alias3"
(
+
LEFT JOIN (t_employee "alias5"
t_employee "alias3"
+
  LEFT JOIN t_employee "alias6" ON "alias5".id_chief = "alias6".id_employee
LEFT JOIN
+
) ON "alias3".id_chief = "alias5".id_employee
(
+
) ON "alias4"."col2" = "alias3".id_employee
t_employee "alias5"
+
ORDER BY "alias4"."col123"
LEFT JOIN
+
</source>
t_employee "alias6"
+
ON "alias5".id_chief = "alias6".id_employee
+
)
+
ON "alias3".id_chief = "alias5".id_employee
+
)
+
ON "alias4"."col2" = "alias3".id_employee
+
order by "alias4"."col123"</pre>
+

Текущая версия на 14:11, 23 марта 2011

Oracle, бывает, очень прикольно исполняет некоторые запросы.

Например, здесь, если раскомментировать /* ORDER BY "alias1".id_employee */, результат запроса меняется!

SELECT
 "alias6".birth_date AS "col4",
 "alias6".e_category AS "col5",
 "alias6".id_chief AS "col6",
 "alias6".id_department AS "col7",
 "alias6".fire_date AS "col8",
 "alias6".first_name AS "col9",
 "alias6".hire_date AS "col10",
 "alias6".id_employee AS "col11",
 "alias6".last_name AS "col12",
 "alias6".dtm_modified AS "col13",
 "alias6".salary AS "col14",
 "alias6".e_sex AS "col15",
 "alias6".id_product AS "col16"
FROM (
 SELECT "alias1".id_employee AS "col123",
  CASE WHEN (EXISTS (
    SELECT '1' AS "col1"
    FROM t_employee "alias2"
    WHERE "alias2".id_chief = "alias1".id_employee
   ))
  THEN ("alias1".id_employee) ELSE ("alias1".id_chief) END AS "col2"
 FROM t_employee "alias1"
 /* ORDER BY "alias1".id_employee - если раскомментировать, результат запроса меняется! */
) "alias4"
LEFT JOIN (t_employee "alias3"
 LEFT JOIN (t_employee "alias5"
  LEFT JOIN t_employee "alias6" ON "alias5".id_chief = "alias6".id_employee
 ) ON "alias3".id_chief = "alias5".id_employee
) ON "alias4"."col2" = "alias3".id_employee
ORDER BY "alias4"."col123"