{"id":36671,"date":"2019-10-31T22:13:01","date_gmt":"2019-10-31T19:13:01","guid":{"rendered":"https:\/\/prohoster.info\/blog\/sql-zanimatelnye-zadachki\/"},"modified":"2019-10-31T22:13:01","modified_gmt":"2019-10-31T19:13:01","slug":"sql-zanimatelnye-zadachki","status":"publish","type":"post","link":"https:\/\/prohoster.info\/hy\/blog\/news\/sql-zanimatelnye-zadachki","title":{"rendered":"SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0412\u043e\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 3-\u0445 \u043b\u0435\u0442 \u044f \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u044e SQL \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u043d\u0433 \u0446\u0435\u043d\u0442\u0440\u0430\u0445, \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 SQL \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0438 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u0445.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0434\u0430\u044e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u0430\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0438 \u043d\u0430\u0434 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043c\u044b \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0431\u0440\u0435\u0439\u043d\u0441\u0442\u043e\u0440\u043c\u044b, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u043c\u0443 \u0438 \u0447\u0435\u0442\u043a\u043e\u043c\u0443 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044e SQL.<\/p>\n<p><img decoding=\"async\" alt=\"SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438\" src=\"\/wp-content\/uploads\/2019\/07\/283f472e0c382c0621ffc14e2ac06881.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nSQL (\u02c8\u025bs\u02c8kju\u02c8\u025bl; \u0430\u043d\u0433\u043b. structured query language \u2014 \u00ab\u044f\u0437\u044b\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432\u00bb) \u2014 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f, \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. <noindex><a rel=\"nofollow\" href=\"https:\/\/ru.wikipedia.org\/wiki\/SQL\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435\u2026 <\/a><\/noindex><\/p>\n<p>\u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431 SQL \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 <noindex><a rel=\"nofollow\" href=\"https:\/\/www.google.com\/search?q=SQL\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432<\/a><\/noindex>.<br \/>\n\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u043f\u0440\u0435\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0446\u0435\u043b\u0438 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u0432\u0430\u0441 SQL \u0441 \u043d\u0443\u043b\u044f.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n\u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<p>\u0411\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0442\u044c \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0443\u044e <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/oracle\/db-sample-schemas\/tree\/master\/human_resources\">\u0441\u0445\u0435\u043c\u0443 HR<\/a><\/noindex> \u0432 Oracle \u0441 \u0435\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 (<noindex><a rel=\"nofollow\" href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/12.2\/comsc\/HR-sample-schema-table-descriptions.html\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/a><\/noindex>):<\/p>\n<p><img decoding=\"async\" alt=\"SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438\" src=\"\/wp-content\/uploads\/2019\/07\/b518c0bedd0d7bbeaedbcc4bd95079cd.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n\u041e\u0442\u043c\u0435\u0447\u0443 \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 SELECT. \u0422\u0443\u0442 \u043d\u0435\u0442 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 DML \u0438 DDL.<\/p>\n<h2>\u0417\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\n<b>Restricting and Sorting Data<\/b><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e\u0431\u043e \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u0445 <br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT * FROM employees\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &#8216;David&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE first_name = 'David';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 job_id \u0440\u0430\u0432\u043d\u044b\u043c &#8216;IT_PROG&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE job_id = 'IT_PROG'\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438\u0437 50\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u0430 (department_id) \u0441 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u043e\u0439(salary), \u0431\u043e\u043b\u044c\u0448\u0435\u0439 4000<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE department_id = 50 AND salary &gt; 4000;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438\u0437 20\u0433\u043e \u0438 \u0438\u0437 30\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u0430 (department_id)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE department_id = 20 OR department_id = 30;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0431\u0443\u043a\u0432\u0430 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0440\u0430\u0432\u043d\u0430 &#8216;a&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE first_name LIKE '%a';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438\u0437 50\u0433\u043e \u0438 \u0438\u0437 80\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u0430 (department_id) \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0431\u043e\u043d\u0443\u0441 (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 commission_pct \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0435)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE     (department_id = 50 OR department_id = 80)\n       AND commission_pct IS NOT NULL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c 2 \u0431\u0443\u043a\u0432\u044b &#8216;n&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE first_name LIKE '%n%n%';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043b\u0438\u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 4 \u0431\u0443\u043a\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE first_name LIKE '%_____%';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0435 \u043e\u0442 8000 \u0434\u043e 9000 (\u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE salary BETWEEN 8000 AND 9000;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0438\u043c\u0432\u043e\u043b &#8216;%&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE first_name LIKE '%%%' ESCAPE '';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 ID \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT DISTINCT manager_id\n  FROM employees\n WHERE manager_id IS NOT NULL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u043e\u0432 \u0441 \u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: Donald(sh_clerk)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name || '(' || LOWER (job_id) || ')' employee FROM employees;\n<\/code><\/pre>\n<p>\n<b>Using Single-Row Functions to Customize Output<\/b><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0434\u043b\u0438\u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 10 \u0431\u0443\u043a\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE LENGTH (first_name) &gt; 10;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0435\u0441\u0442\u044c \u0431\u0443\u043a\u0432\u0430 &#8216;b&#8217; (\u0431\u0435\u0437 \u0443\u0447\u0435\u0442\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE INSTR (LOWER (first_name), 'b') &gt; 0;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0443\u043c 2 \u0431\u0443\u043a\u0432\u044b &#8216;a&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE INSTR (LOWER (first_name),'a',1,2) &gt; 0;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u0440\u0430\u0442\u043d\u0430 1000<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE MOD (salary, 1000) = 0;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 3\u0445 \u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430 \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u043e\u043c\u0435\u0440 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0425\u0425\u0425.\u0425\u0425\u0425.\u0425\u0425\u0425\u0425<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT phone_number, SUBSTR (phone_number, 1, 3) new_phone_number\n  FROM employees\n WHERE phone_number LIKE '___.___.____';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Departments. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438\u0437 \u0438\u043c\u0435\u043d\u0438 \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0442\u0435\u0445 \u0443 \u043a\u043e\u0433\u043e \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT department_name,\n       SUBSTR (department_name, 1, INSTR (department_name, ' ')-1)\n           first_word\n  FROM departments\n WHERE INSTR (department_name, ' ') &gt; 0;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0431\u0435\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0431\u0443\u043a\u0432\u044b \u0432 \u0438\u043c\u0435\u043d\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name, SUBSTR (first_name, 2, LENGTH (first_name) - 2) new_name\n  FROM employees;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0431\u0443\u043a\u0432\u0430 \u0432 \u0438\u043c\u0435\u043d\u0438 \u0440\u0430\u0432\u043d\u0430 &#8216;m&#8217; \u0438 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 \u0438\u043c\u0435\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 5\u0442\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE SUBSTR (first_name, -1) = 'm' AND LENGTH(first_name)&gt;5;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Dual. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u0442\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u044f\u0442\u043d\u0438\u0446\u044b<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT NEXT_DAY (SYSDATE, 'FRIDAY') next_friday FROM DUAL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 17 \u043b\u0435\u0442<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE MONTHS_BETWEEN (SYSDATE, hire_date) \/ 12 &gt; 17;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f \u0446\u0438\u0444\u0440\u0430 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0433\u043e \u043d\u043e\u043c\u0435\u0440\u0430 \u043d\u0435\u0447\u0435\u0442\u043d\u0430\u044f \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3\u0435\u0445 \u0447\u0438\u0441\u0435\u043b \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u043e\u0447\u043a\u043e\u0439<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE     MOD (SUBSTR (phone_number, -1), 2) != 0\n       AND INSTR (phone_number,'.',1,3) = 0;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 job_id \u043f\u043e\u0441\u043b\u0435 \u0437\u043d\u0430\u043a\u0430 &#8216;_&#8217; \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 3 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 &#8216;_&#8217; \u043d\u0435 \u0440\u0430\u0432\u043d\u043e &#8216;CLERK&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE     LENGTH (SUBSTR (job_id, INSTR (job_id, '_') + 1)) &gt; 3\n       AND SUBSTR (job_id, INSTR (job_id, '_') + 1) != 'CLERK';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0437\u0430\u043c\u0435\u043d\u0438\u0432 \u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 PHONE_NUMBER \u0432\u0441\u0435 &#8216;.&#8217; \u043d\u0430 &#8216;-&#8216;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT phone_number, REPLACE (phone_number, '.', '-') new_phone_number\n  FROM employees;\n<\/code><\/pre>\n<p>\n<b>Using Conversion Functions and Conditional Expressions<\/b><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u0435\u043d\u044c \u043c\u0435\u0441\u044f\u0446\u0430 (\u043b\u044e\u0431\u043e\u0433\u043e)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE TO_CHAR (hire_date, 'DD') = '01';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 2008\u043e\u043c \u0433\u043e\u0434\u0443<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE TO_CHAR (hire_date, 'YYYY') = '2008';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 DUAL. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0437\u0430\u0432\u0442\u0440\u0430\u0448\u043d\u044e\u044e \u0434\u0430\u0442\u0443 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: Tomorrow is Second day of January<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT TO_CHAR (SYSDATE, 'fm\"\"Tomorrow is \"\"Ddspth \"\"day of\"\" Month')     info\n  FROM DUAL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u0434\u0430\u0442\u0443 \u043f\u0440\u0438\u0445\u043e\u0434\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: 21st of June, 2007<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name, TO_CHAR (hire_date, 'fmddth \"\"of\"\" Month, YYYY') hire_date\n  FROM employees;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u043e\u0432 \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0430\u043c\u0438 \u043d\u0430 20%. \u0417\u0430\u0440\u043f\u043b\u0430\u0442\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0434\u043e\u043b\u043b\u0430\u0440\u0430<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name, TO_CHAR (salary + salary * 0.20, 'fm$999,999.00') new_salary\n  FROM employees;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0448\u0438 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u0444\u0435\u0432\u0440\u0430\u043b\u0435 2007\u0433\u043e \u0433\u043e\u0434\u0430.<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE hire_date BETWEEN TO_DATE ('01.02.2007', 'DD.MM.YYYY')\n                     AND LAST_DAY (TO_DATE ('01.02.2007', 'DD.MM.YYYY'));\n\nSELECT *\n  FROM employees\n WHERE to_char(hire_date,'MM.YYYY') = '02.2007'; \n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 DUAL. \u0412\u044b\u0432\u0435\u0437\u0442\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0434\u0430\u0442\u0443, + \u0441\u0435\u043a\u0443\u043d\u0434\u0430, + \u043c\u0438\u043d\u0443\u0442\u0430, + \u0447\u0430\u0441, + \u0434\u0435\u043d\u044c, + \u043c\u0435\u0441\u044f\u0446, + \u0433\u043e\u0434<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT SYSDATE                          now,\n       SYSDATE + 1 \/ (24 * 60 * 60)     plus_second,\n       SYSDATE + 1 \/ (24 * 60)          plus_minute,\n       SYSDATE + 1 \/ 24                 plus_hour,\n       SYSDATE + 1                      plus_day,\n       ADD_MONTHS (SYSDATE, 1)          plus_month,\n       ADD_MONTHS (SYSDATE, 12)         plus_year\n  FROM DUAL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u043f\u043e\u043b\u043d\u044b\u043c\u0438 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0430\u043c\u0438 (salary + commission_pct(%)) \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: $24,000.00<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name, salary, TO_CHAR (salary + salary * NVL (commission_pct, 0), 'fm$99,999.00') full_salary\n  FROM employees;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0431\u043e\u043d\u0443\u0441\u043e\u0432 \u043a \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0435 (Yes\/No)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name, commission_pct, NVL2 (commission_pct, 'Yes', 'No') has_bonus\n  FROM employees;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430: \u041c\u0435\u043d\u044c\u0448\u0435 5000 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f Low level, \u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u043d\u043e 5000 \u0438 \u043c\u0435\u043d\u044c\u0448\u0435 10000 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f Normal level, \u0411\u043e\u043b\u044c\u0448\u0435 \u0438\u043e\u0438 \u0440\u0430\u0432\u043d\u043e 10000 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f High level<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name,\n       salary,\n       CASE\n           WHEN salary &lt; 5000 THEN 'Low'\n           WHEN salary &gt;= 5000 AND salary &lt; 10000 THEN 'Normal'\n           ELSE 'High'\n       END salary_level\n  FROM employees;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Countries. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0435\u0433\u0438\u043e\u043d \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f: 1-Europe, 2-America, 3-Asia, 4-Africa (\u0431\u0435\u0437 Join)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT country_name country,\n       DECODE (region_id,\n               1, 'Europe',\n               2, 'America',\n               3, 'Asia',\n               4, 'Africa',\n               'Unknown')\n           region\n  FROM countries;\n\nSELECT country_name\n           country,\n       CASE region_id\n           WHEN 1 THEN 'Europe'\n           WHEN 2 THEN 'America'\n           WHEN 3 THEN 'Asia'\n           WHEN 4 THEN 'Africa'\n           ELSE 'Unknown'\n       END\n           region\n  FROM countries;\n<\/code><\/pre>\n<p>\n<b>Reporting Aggregated Data Using the Group Functions<\/b><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0440\u0442 \u043f\u043e department_id \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u043e\u0439, \u0441 \u0440\u0430\u043d\u043d\u0435\u0439 \u0438 \u043f\u043e\u0437\u0434\u043d\u0435\u0439 \u0434\u0430\u0442\u043e\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0430 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u0441 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u0432 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432. \u0421\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 (\u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT department_id,\n         MIN (salary) min_salary,\n         MAX (salary) max_salary,\n         MIN (hire_date) min_hire_date,\n         MAX (hire_date) max_hire_Date,\n         COUNT (*) count\n    FROM employees\nGROUP BY department_id\norder by count(*) desc;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0438\u043c\u0435\u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0431\u0443\u043a\u0432\u044b? \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443. \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0433\u0434\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u043e\u043b\u044c\u0448\u0435 1<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT SUBSTR (first_name, 1, 1) first_char, COUNT (*)\n    FROM employees\nGROUP BY SUBSTR (first_name, 1, 1)\n  HAVING COUNT (*) &gt; 1\nORDER BY 2 DESC;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0443?<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT department_id, salary, COUNT (*)\n    FROM employees\nGROUP BY department_id, salary\n  HAVING COUNT (*) &gt; 1;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0440\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT TO_CHAR (hire_Date, 'Day') day, COUNT (*)\n    FROM employees\nGROUP BY TO_CHAR (hire_Date, 'Day')\nORDER BY 2 DESC;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0440\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043f\u0440\u0438\u043d\u044f\u043b\u0438 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e \u0433\u043e\u0434\u0430\u043c. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT TO_CHAR (hire_date, 'YYYY') year, COUNT (*)\n    FROM employees\nGROUP BY TO_CHAR (hire_date, 'YYYY');\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT COUNT (COUNT (*))     department_count\n    FROM employees\n   WHERE department_id IS NOT NULL\nGROUP BY department_id;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a department_id \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 30 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT department_id\n    FROM employees\nGROUP BY department_id\n  HAVING COUNT (*) &gt; 30;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a department_id \u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0443 \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0435. <br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT department_id, ROUND (AVG (salary)) avg_salary\n    FROM employees\nGROUP BY department_id;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Countries. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a region_id \u0441\u0443\u043c\u043c\u0430 \u0432\u0441\u0435\u0445 \u0431\u0443\u043a\u0432 \u0432\u0441\u0435\u0445 country_name \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0435 60\u0442\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT region_id\n    FROM countries\nGROUP BY region_id\n  HAVING SUM (LENGTH (country_name)) &gt; 60;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a department_id \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 (&gt;1) job_id<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT department_id\n    FROM employees\nGROUP BY department_id\n  HAVING COUNT (DISTINCT job_id) &gt; 1;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a manager_id \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 5 \u0438 \u0441\u0443\u043c\u043c\u0430 \u0432\u0441\u0435\u0445 \u0437\u0430\u0440\u043f\u043b\u0430\u0442 \u0435\u0433\u043e \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0435 50000<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT manager_id\n    FROM employees\nGROUP BY manager_id\n  HAVING COUNT (*) &gt; 5 AND SUM (salary) &gt; 50000;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a manager_id \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0430 \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u0435 \u043e\u0442 6000 \u0434\u043e 9000 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0431\u043e\u043d\u0443\u0441\u044b (commission_pct \u043f\u0443\u0441\u0442\u043e\u0439)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT manager_id, AVG (salary) avg_salary\n    FROM employees\n   WHERE commission_pct IS NULL\nGROUP BY manager_id\n  HAVING AVG (salary) BETWEEN 6000 AND 9000;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0443 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 job_id \u043a\u043e\u0442\u043e\u0440\u044b\u0437 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043b\u043e\u0432\u043e &#8216;CLERK&#8217;<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT MAX (salary) max_salary\n  FROM employees\n WHERE job_id LIKE '%CLERK';\n\nSELECT MAX (salary) max_salary\n  FROM employees\n WHERE SUBSTR (job_id, -5) = 'CLERK';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0443 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u0430\u0440\u043f\u043b\u0430\u0442 \u043f\u043e \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0443<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT MAX (AVG (salary))\n    FROM employees\nGROUP BY department_id;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0443\u043a\u0432 \u0432 \u0438\u043c\u0435\u043d\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0443 \u043a\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 5 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 20. \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0434\u043b\u0438\u043d\u043d\u0435 \u0438\u043c\u0435\u043d\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT LENGTH (first_name), COUNT (*)\n    FROM employees\nGROUP BY LENGTH (first_name)\n  HAVING LENGTH (first_name) &gt; 5 AND COUNT (*) &gt; 20\nORDER BY LENGTH (first_name);\n\n  SELECT LENGTH (first_name), COUNT (*)\n    FROM employees\n   WHERE LENGTH (first_name) &gt; 5\nGROUP BY LENGTH (first_name)\n  HAVING COUNT (*) &gt; 20\nORDER BY LENGTH (first_name);\n<\/code><\/pre>\n<p>\n<b>Displaying Data from Multiple Tables Using Joins<\/b><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments, Locations, Countries, Regions. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0433\u0438\u043e\u043d\u043e\u0432 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0440\u0435\u0433\u0438\u043e\u043d\u0435<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT region_name, COUNT (*)\n    FROM employees e\n         JOIN departments d ON (e.department_id = d.department_id)\n         JOIN locations l ON (d.location_id = l.location_id)\n         JOIN countries c ON (l.country_id = c.country_id)\n         JOIN regions r ON (c.region_id = r.region_id)\nGROUP BY region_name;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments, Locations, Countries, Regions. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0435:<br \/>\nFirst_name, Last_name, Departament, Job, Street, Country, Region<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT First_name,\n       Last_name,\n       Department_name,\n       Job_id,\n       street_address,\n       Country_name,\n       Region_name\n  FROM employees  e\n       JOIN departments d ON (e.department_id = d.department_id)\n       JOIN locations l ON (d.location_id = l.location_id)\n       JOIN countries c ON (l.country_id = c.country_id)\n       JOIN regions r ON (c.region_id = r.region_id);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0432 \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 6\u0442\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">  SELECT man.first_name, COUNT (*)\n    FROM employees emp JOIN employees man ON (emp.manager_id = man.employee_id)\nGROUP BY man.first_name\n  HAVING COUNT (*) &gt; 6;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438 \u043a\u043e\u043c\u0443 \u043d\u0435 \u043f\u043e\u0434\u0447\u0438\u043d\u044f\u044e\u0442\u0441\u044f<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT emp.first_name\n  FROM employees  emp\n       LEFT JOIN employees man ON (emp.manager_id = man.employee_id)\n WHERE man.FIRST_NAME IS NULL;\n\nSELECT first_name\n  FROM employees\n WHERE manager_id IS NULL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Job_history. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Employee \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 Job_history \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0438 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u043f\u043e\u0440\u0442 \u043e \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u0445 \u0438 \u043e \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0435 \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 (\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u043b\u0438 \u043f\u043e\u043a\u0438\u043d\u0443\u043b \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044e \u0441 \u0434\u0430\u0442\u043e\u0439 \u0443\u0445\u043e\u0434\u0430)<br \/>\n\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>\nfirst_name | status<br \/>\nJennifer | Left the company at 31 of December, 2006<br \/>\nClara | Currently Working<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name,\n       NVL2 (\n           end_date,\n           TO_CHAR (end_date, 'fm\"\"Left the company at\"\" DD \"\"of\"\" Month, YYYY'),\n           'Currently Working')\n           status\n  FROM employees e LEFT JOIN job_history j ON (e.employee_id = j.employee_id);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments, Locations, Countries, Regions. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0436\u0438\u0432\u0443\u0442 \u0432 Europe (region_name)<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\"> SELECT first_name\n  FROM employees\n       JOIN departments USING (department_id)\n       JOIN locations USING (location_id)\n       JOIN countries USING (country_id)\n       JOIN regions USING (region_id)\n WHERE region_name = 'Europe';\n \n SELECT first_name\n  FROM employees  e\n       JOIN departments d ON (e.department_id = d.department_id)\n       JOIN locations l ON (d.location_id = l.location_id)\n       JOIN countries c ON (l.country_id = c.country_id)\n       JOIN regions r ON (c.region_id = r.region_id)\n WHERE region_name = 'Europe';\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 30\u0442\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT department_name, COUNT (*)\n    FROM employees e JOIN departments d ON (e.department_id = d.department_id)\nGROUP BY department_name\n  HAVING COUNT (*) &gt; 30;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u043d\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0435<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name\n  FROM employees  e\n       LEFT JOIN departments d ON (e.department_id = d.department_id)\n WHERE d.department_name IS NULL;\n\nSELECT first_name\n  FROM employees\n WHERE department_id IS NULL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT department_name\n  FROM employees  e\n       RIGHT JOIN departments d ON (e.department_id = d.department_id)\n WHERE first_name IS NULL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u043d\u0438 \u043a\u043e\u0433\u043e \u0432 \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u0438\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT man.first_name\n  FROM employees  emp\n       RIGHT JOIN employees man ON (emp.manager_id = man.employee_id)\n WHERE emp.FIRST_NAME IS NULL;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Jobs, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: First_name, Job_title, Department_name.<br \/>\n\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>\nFirst_name | Job_title | Department_name<br \/>\nDonald | Shipping | Clerk Shipping<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name, job_title, department_name\n  FROM employees  e\n       JOIN jobs j ON (e.job_id = j.job_id)\n       JOIN departments d ON (d.department_id = e.department_id);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 2005\u043e\u043c \u0433\u043e\u0434\u0443 \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e \u0441\u0430\u043c\u0438 \u044d\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u043e 2005 \u0433\u043e\u0434\u0430<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT emp.*\n  FROM employees emp JOIN employees man ON (emp.manager_id = man.employee_id)\n WHERE     TO_CHAR (man.hire_date, 'YYYY') = '2005'\n       AND emp.hire_date &lt; TO_DATE ('01012005', 'DDMMYYYY');\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u044f\u043d\u0432\u0430\u0440\u0435 \u043c\u0435\u0441\u044f\u0446\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0438 \u0434\u043b\u0438\u043d\u0430 job_title \u044d\u0442\u0438\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 15\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT emp.*\n  FROM employees  emp\n       JOIN employees man ON (emp.manager_id = man.employee_id)\n       JOIN jobs j ON (emp.job_id = j.job_id)\n WHERE TO_CHAR (man.hire_date, 'MM') = '01' AND LENGTH (j.job_title) &gt; 15;\n<\/code><\/pre>\n<p>\n<b>Using Subqueries to Solve Queries<\/b><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u0441\u0430\u043c\u044b\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c.<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE LENGTH (first_name) =\n       (SELECT MAX (LENGTH (first_name)) FROM employees);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0441 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0439 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u044b \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432.<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE salary &gt; (SELECT AVG (salary) FROM employees);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departments, Locations. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0433\u043e\u0440\u043e\u0434 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0438 \u0432 \u0441\u0443\u043c\u043c\u0435 \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u0432\u0441\u0435\u0445.<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT city\n    FROM employees e\n         JOIN departments d ON (e.department_id = d.department_id)\n         JOIN locations l ON (d.location_id = l.location_id)\nGROUP BY city\n  HAVING SUM (salary) =\n         (  SELECT MIN (SUM (salary))\n              FROM employees e\n                   JOIN departments d ON (e.department_id = d.department_id)\n                   JOIN locations l ON (d.location_id = l.location_id)\n          GROUP BY city);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0443 \u0431\u043e\u043b\u044c\u0448\u0435 15000.<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE manager_id IN (SELECT employee_id\n                        FROM employees\n                       WHERE salary &gt; 15000)\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM departments\n WHERE department_id NOT IN (SELECT department_id\n                               FROM employees\n                              WHERE department_id IS NOT NULL);\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c\u0438<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE employee_id NOT IN (SELECT manager_id\n                             FROM employees\n                            WHERE manager_id IS NOT NULL)\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435\u0445 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0432 \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 6\u0442\u0438 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees e\n WHERE (SELECT COUNT (*)\n          FROM employees\n         WHERE manager_id = e.employee_id) &gt; 6;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0432 \u0434\u0435\u043f\u0430\u0440\u0442\u0430\u043c\u0435\u043d\u0442\u0435 IT<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE department_id = (SELECT department_id\n                          FROM departments\n                         WHERE department_name = 'IT');\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees, Jobs, Departaments. \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435: First_name, Job_title, Department_name.<br \/>\n\u041f\u0440\u0438\u043c\u0435\u0440:<br \/>\nFirst_name | Job_title | Department_name<br \/>\nDonald | Shipping | Clerk Shipping<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT first_name,\n       (SELECT job_title\n          FROM jobs\n         WHERE job_id = e.job_id)\n           job_title,\n       (SELECT department_name\n          FROM departments\n         WHERE department_id = e.department_id)\n           department_name\n  FROM employees e;\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 2005\u043e\u043c \u0433\u043e\u0434\u0443 \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e \u0441\u0430\u043c\u0438 \u044d\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u043d\u0438\u043a\u0438 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0434\u043e 2005 \u0433\u043e\u0434\u0430<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees\n WHERE     manager_id IN (SELECT employee_id\n                            FROM employees\n                           WHERE TO_CHAR (hire_date, 'YYYY') = '2005')\n       AND hire_date &lt; TO_DATE ('01012005', 'DDMMYYYY');\n<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 Employees. \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u044f\u043d\u0432\u0430\u0440\u0435 \u043c\u0435\u0441\u044f\u0446\u0435 \u043b\u044e\u0431\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0438 \u0434\u043b\u0438\u043d\u0430 job_title \u044d\u0442\u0438\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 15\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432<br \/>\n<b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<pre><code class=\"sql\">SELECT *\n  FROM employees e\n WHERE     manager_id IN (SELECT employee_id\n                            FROM employees\n                           WHERE TO_CHAR (hire_date, 'MM') = '01')\n       AND (SELECT LENGTH (job_title)\n              FROM jobs\n             WHERE job_id = e.job_id) &gt; 15;\n<\/code><\/pre>\n<p>\n<b>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0451.<\/b><\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u044b\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438 \u0438 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438. <br \/>\n\u0411\u0443\u0434\u0443 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447.<br \/>\n\u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043b\u044e\u0431\u044b\u043c \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f\u043c \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p>P.S.: \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0443 \u0442\u043e \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u043f\u0440\u0438\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 SELECT, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0432 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e.<br \/>\n<br \/>\u0531\u0572\u0562\u0575\u0578\u0582\u0580: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/461567\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0425\u0430\u0431\u0440! \u0412\u043e\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 3-\u0445 \u043b\u0435\u0442 \u044f \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u044e SQL \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u043d\u0433 \u0446\u0435\u043d\u0442\u0440\u0430\u0445, \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 SQL \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0438 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u0445. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0434\u0430\u044e [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":27465,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[702],"tags":[],"class_list":["post-36671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0425\u0430\u0431\u0440! \u0412\u043e\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 3-\u0445 \u043b\u0435\u0442 \u044f \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u044e SQL \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u043d\u0433 \u0446\u0435\u043d\u0442\u0440\u0430\u0445, \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 SQL \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/hy\/blog\/news\/sql-zanimatelnye-zadachki\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0425\u0430\u0431\u0440! \u0412\u043e\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 3-\u0445 \u043b\u0435\u0442 \u044f \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u044e SQL \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u043d\u0433 \u0446\u0435\u043d\u0442\u0440\u0430\u0445, \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 SQL \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/hy\/blog\/news\/sql-zanimatelnye-zadachki\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:13:01+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T19:13:01+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 | ProHoster","description":"\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0425\u0430\u0431\u0440! \u0412\u043e\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 3-\u0445 \u043b\u0435\u0442 \u044f \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u044e SQL \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u043d\u0433 \u0446\u0435\u043d\u0442\u0440\u0430\u0445, \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 SQL \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e.","canonical_url":"https:\/\/prohoster.info\/hy\/blog\/news\/sql-zanimatelnye-zadachki","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438 | ProHoster","og:description":"\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439, \u0425\u0430\u0431\u0440! \u0412\u043e\u0442 \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 3-\u0445 \u043b\u0435\u0442 \u044f \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u044e SQL \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0438\u043d\u0433 \u0446\u0435\u043d\u0442\u0440\u0430\u0445, \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043c\u043e\u0438\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0441\u0442\u0443\u0434\u0435\u043d\u0442\u044b \u043e\u0441\u0432\u0430\u0438\u0432\u0430\u044e\u0442 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 SQL \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0434 \u043d\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0443, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e.","og:url":"https:\/\/prohoster.info\/hy\/blog\/news\/sql-zanimatelnye-zadachki","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:13:01+00:00","article:modified_time":"2019-10-31T19:13:01+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"36671","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-22 04:21:19","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 01:40:23","updated":"2026-01-22 04:21:19","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/posts\/36671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/comments?post=36671"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/posts\/36671\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/media\/27465"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/media?parent=36671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/categories?post=36671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/hy\/wp-json\/wp\/v2\/tags?post=36671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}