Oracle sucks
Материал из YourcmcWiki
Версия от 14:11, 23 марта 2011; VitaliyFilippov (обсуждение | вклад)
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"