{"id":292774,"date":"2019-07-30T15:00:57","date_gmt":"2019-07-30T15:00:57","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=292774"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=292774","title":{"rendered":"SQL. \u0417\u0430\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u043a\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\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\" src=\"https:\/\/habrastorage.org\/webt\/gr\/ue\/1m\/grue1mys5l7b9rieubqlrxu5jfo.png\"><\/p>\n<p>  SQL (\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. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/SQL\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435\u2026 <\/a><\/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 <a href=\"https:\/\/www.google.com\/search?q=SQL\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432<\/a>.<br \/>  \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 \/>  <a name=\"habracut\"><\/a><br \/>  \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 <a href=\"https:\/\/github.com\/oracle\/db-sample-schemas\/tree\/master\/human_resources\">\u0441\u0445\u0435\u043c\u0443 HR<\/a> \u0432 Oracle \u0441 \u0435\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 (<a 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>):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lw\/4k\/mm\/lw4kmmf6abadgz5cdtaf2jsggyu.gif\"><br \/>  \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>  <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   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT * FROM employees <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE first_name = 'David'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE job_id = 'IT_PROG' <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE department_id = 50 AND salary &gt; 4000; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE department_id = 20 OR department_id = 30; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE first_name LIKE '%a'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE     (department_id = 50 OR department_id = 80)        AND commission_pct IS NOT NULL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE first_name LIKE '%n%n%'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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\u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 4 \u0431\u0443\u043a\u0432  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE first_name LIKE '%_____%'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE salary BETWEEN 8000 AND 9000; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE first_name LIKE '%\\%%' ESCAPE '\\'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT DISTINCT manager_id   FROM employees  WHERE manager_id IS NOT NULL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name || '(' || LOWER (job_id) || ')' employee FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <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\u043d\u0430 \u0438\u043c\u0435\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 10 \u0431\u0443\u043a\u0432  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE LENGTH (first_name) &gt; 10; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE INSTR (LOWER (first_name), 'b') &gt; 0; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE INSTR (LOWER (first_name),'a',1,2) &gt; 0; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE MOD (salary, 1000) = 0; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT phone_number, SUBSTR (phone_number, 1, 3) new_phone_number   FROM employees  WHERE phone_number LIKE '___.___.____'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT department_name,        SUBSTR (department_name, 1, INSTR (department_name, ' ')-1)            first_word   FROM departments  WHERE INSTR (department_name, ' ') &gt; 0; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name, SUBSTR (first_name, 2, LENGTH (first_name) - 2) new_name   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE SUBSTR (first_name, -1) = 'm' AND LENGTH(first_name)&gt;5; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT NEXT_DAY (SYSDATE, 'FRIDAY') next_friday FROM DUAL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE MONTHS_BETWEEN (SYSDATE, hire_date) \/ 12 &gt; 17; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE     MOD (SUBSTR (phone_number, -1), 2) != 0        AND INSTR (phone_number,'.',1,3) = 0; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE     LENGTH (SUBSTR (job_id, INSTR (job_id, '_') + 1)) &gt; 3        AND SUBSTR (job_id, INSTR (job_id, '_') + 1) != 'CLERK'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT phone_number, REPLACE (phone_number, '.', '-') new_phone_number   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE TO_CHAR (hire_date, 'DD') = '01'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE TO_CHAR (hire_date, 'YYYY') = '2008'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT TO_CHAR (SYSDATE, 'fm\"\"Tomorrow is \"\"Ddspth \"\"day of\"\" Month')     info   FROM DUAL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name, TO_CHAR (hire_date, 'fmddth \"\"of\"\" Month, YYYY') hire_date   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name, TO_CHAR (salary * 0.20, 'fm$999,999.00') new_salary   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE hire_date BETWEEN TO_DATE ('01.02.2007', 'DD.MM.YYYY')                      AND LAST_DAY (TO_DATE ('01.02.2007', 'DD.MM.YYYY'));  SELECT *   FROM employees  WHERE to_char(hire_date,'MM.YYYY') = '02.2007';  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT SYSDATE                          now,        SYSDATE + 1 \/ (24 * 60 * 60)     plus_second,        SYSDATE + 1 \/ (24 * 60)          plus_minute,        SYSDATE + 1 \/ 24                 plus_hour,        SYSDATE + 1                      plus_day,        ADD_MONTHS (SYSDATE, 1)          plus_month,        ADD_MONTHS (SYSDATE, 12)         plus_year   FROM DUAL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name, salary, TO_CHAR (salary + salary * NVL (commission_pct, 0), 'fm$99,999.00') full_salary   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name, commission_pct, NVL2 (commission_pct, 'Yes', 'No') has_bonus   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name,        salary,        CASE            WHEN salary &lt; 5000 THEN 'Low'            WHEN salary &gt;= 5000 AND salary &lt; 10000 THEN 'Normal'            ELSE 'High'        END salary_level   FROM employees; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT country_name country,        DECODE (region_id,                1, 'Europe',                2, 'America',                3, 'Asia',                4, 'Africa',                'Unknown')            region   FROM countries;  SELECT country_name            country,        CASE region_id            WHEN 1 THEN 'Europe'            WHEN 2 THEN 'America'            WHEN 3 THEN 'Asia'            WHEN 4 THEN 'Africa'            ELSE 'Unknown'        END            region   FROM countries; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT department_id,          MIN (salary) min_salary,          MAX (salary) max_salary,          MIN (hire_date) min_hire_date,          MAX (hire_date) max_hire_Date,          COUNT (*) count     FROM employees GROUP BY department_id order by count(*) desc; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT SUBSTR (first_name, 1, 1) first_char, COUNT (*)     FROM employees GROUP BY SUBSTR (first_name, 1, 1)   HAVING COUNT (*) &gt; 1 ORDER BY 2 DESC; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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?  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT department_id, salary, COUNT (*)     FROM employees GROUP BY department_id, salary   HAVING COUNT (*) &gt; 1; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT TO_CHAR (hire_Date, 'Day') day, COUNT (*)     FROM employees GROUP BY TO_CHAR (hire_Date, 'Day') ORDER BY 2 DESC; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT TO_CHAR (hire_date, 'YYYY') year, COUNT (*)     FROM employees GROUP BY TO_CHAR (hire_date, 'YYYY'); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT COUNT (COUNT (*))     department_count     FROM employees    WHERE department_id IS NOT NULL GROUP BY department_id; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT department_id     FROM employees GROUP BY department_id   HAVING COUNT (*) &gt; 30; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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.   <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT department_id, ROUND (AVG (salary)) avg_salary     FROM employees GROUP BY department_id; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT region_id     FROM countries GROUP BY region_id   HAVING SUM (LENGTH (country_name)) &gt; 60; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT department_id     FROM employees GROUP BY department_id   HAVING COUNT (DISTINCT job_id) &gt; 1; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT manager_id     FROM employees GROUP BY manager_id   HAVING COUNT (*) &gt; 5 AND SUM (salary) &gt; 50000; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT manager_id, AVG (salary) avg_salary     FROM employees    WHERE commission_pct IS NULL GROUP BY manager_id   HAVING AVG (salary) BETWEEN 6000 AND 9000; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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;  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT MAX (salary) max_salary   FROM employees  WHERE job_id LIKE '%CLERK';  SELECT MAX (salary) max_salary   FROM employees  WHERE SUBSTR (job_id, -5) = 'CLERK'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT MAX (AVG (salary))     FROM employees GROUP BY department_id; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT LENGTH (first_name), COUNT (*)     FROM employees GROUP BY LENGTH (first_name)   HAVING LENGTH (first_name) &gt; 5 AND COUNT (*) &gt; 20 ORDER BY LENGTH (first_name);    SELECT LENGTH (first_name), COUNT (*)     FROM employees    WHERE LENGTH (first_name) &gt; 5 GROUP BY LENGTH (first_name)   HAVING COUNT (*) &gt; 20 ORDER BY LENGTH (first_name); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT region_name, COUNT (*)     FROM employees e          JOIN departments d ON (e.department_id = d.department_id)          JOIN locations l ON (d.location_id = l.location_id)          JOIN countries c ON (l.country_id = c.country_id)          JOIN regions r ON (c.region_id = r.region_id) GROUP BY region_name; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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 \/>  First_name, Last_name, Departament, Job, Street, Country, Region  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT First_name,        Last_name,        Department_name,        Job_id,        street_address,        Country_name,        Region_name   FROM employees  e        JOIN departments d ON (e.department_id = d.department_id)        JOIN locations l ON (d.location_id = l.location_id)        JOIN countries c ON (l.country_id = c.country_id)        JOIN regions r ON (c.region_id = r.region_id); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">  SELECT man.first_name, COUNT (*)     FROM employees emp JOIN employees man ON (emp.manager_id = man.employee_id) GROUP BY man.first_name   HAVING COUNT (*) &gt; 6; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT emp.first_name   FROM employees  emp        LEFT JOIN employees man ON (emp.manager_id = man.employee_id)  WHERE man.FIRST_NAME IS NULL;  SELECT first_name   FROM employees  WHERE manager_id IS NULL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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\u0434\u0443\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 \/>  \u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  first_name | status<br \/>  Jennifer | Left the company at 31 of December, 2006<br \/>  Clara | Currently Working  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name,        NVL2 (            end_date,            TO_CHAR (end_date, 'fm\"\"Left the company at\"\" DD \"\"of\"\" Month, YYYY'),            'Currently Working')            status   FROM employees e LEFT JOIN job_history j ON (e.employee_id = j.employee_id); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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)  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\"> SELECT first_name   FROM employees        JOIN departments USING (department_id)        JOIN locations USING (location_id)        JOIN countries USING (country_id)        JOIN regions USING (region_id)  WHERE region_name = 'Europe';    SELECT first_name   FROM employees  e        JOIN departments d ON (e.department_id = d.department_id)        JOIN locations l ON (d.location_id = l.location_id)        JOIN countries c ON (l.country_id = c.country_id)        JOIN regions r ON (c.region_id = r.region_id)  WHERE region_name = 'Europe'; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT department_name, COUNT (*)     FROM employees e JOIN departments d ON (e.department_id = d.department_id) GROUP BY department_name   HAVING COUNT (*) &gt; 30; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name   FROM employees  e        LEFT JOIN departments d ON (e.department_id = d.department_id)  WHERE d.department_name IS NULL;  SELECT first_name   FROM employees  WHERE department_id IS NULL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT department_name   FROM employees  e        RIGHT JOIN departments d ON (e.department_id = d.department_id)  WHERE first_name IS NULL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT man.first_name   FROM employees  emp        RIGHT JOIN employees man ON (emp.manager_id = man.employee_id)  WHERE emp.FIRST_NAME IS NULL; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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 \/>  \u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  First_name | Job_title | Department_name<br \/>  Donald | Shipping | Clerk Shipping  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name, job_title, department_name   FROM employees  e        JOIN jobs j ON (e.job_id = j.job_id)        JOIN departments d ON (d.department_id = e.department_id); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT emp.*   FROM employees emp JOIN employees man ON (emp.manager_id = man.employee_id)  WHERE     TO_CHAR (man.hire_date, 'YYYY') = '2005'        AND emp.hire_date &lt; TO_DATE ('01012005', 'DDMMYYYY'); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT emp.*   FROM employees  emp        JOIN employees man ON (emp.manager_id = man.employee_id)        JOIN jobs j ON (emp.job_id = j.job_id)  WHERE TO_CHAR (man.hire_date, 'MM') = '01' AND LENGTH (j.job_title) &gt; 15; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <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.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE LENGTH (first_name) =        (SELECT MAX (LENGTH (first_name)) FROM employees); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE salary &gt; (SELECT AVG (salary) FROM employees); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT city     FROM employees e          JOIN departments d ON (e.department_id = d.department_id)          JOIN locations l ON (d.location_id = l.location_id) GROUP BY city   HAVING SUM (salary) =          (  SELECT MIN (SUM (salary))               FROM employees e                    JOIN departments d ON (e.department_id = d.department_id)                    JOIN locations l ON (d.location_id = l.location_id)           GROUP BY city); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE manager_id IN (SELECT employee_id                         FROM employees                        WHERE salary &gt; 15000) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM departments  WHERE department_id NOT IN (SELECT department_id                                FROM employees                               WHERE department_id IS NOT NULL); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE employee_id NOT IN (SELECT manager_id                              FROM employees                             WHERE manager_id IS NOT NULL) <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees e  WHERE (SELECT COUNT (*)           FROM employees          WHERE manager_id = e.employee_id) &gt; 6; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE department_id = (SELECT department_id                           FROM departments                          WHERE department_name = 'IT'); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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 \/>  \u041f\u0440\u0438\u043c\u0435\u0440:<br \/>  First_name | Job_title | Department_name<br \/>  Donald | Shipping | Clerk Shipping  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT first_name,        (SELECT job_title           FROM jobs          WHERE job_id = e.job_id)            job_title,        (SELECT department_name           FROM departments          WHERE department_id = e.department_id)            department_name   FROM employees e; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees  WHERE     manager_id IN (SELECT employee_id                             FROM employees                            WHERE TO_CHAR (hire_date, 'YYYY') = '2005')        AND hire_date &lt; TO_DATE ('01012005', 'DDMMYYYY'); <\/code><\/pre>\n<p>  <\/div>\n<\/div>\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\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  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"sql\">SELECT *   FROM employees e  WHERE     manager_id IN (SELECT employee_id                             FROM employees                            WHERE TO_CHAR (hire_date, 'MM') = '01')        AND (SELECT LENGTH (job_title)               FROM jobs              WHERE job_id = e.job_id) &gt; 15; <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <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 \/>  \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 \/>  \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.<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/461567\/\"> https:\/\/habr.com\/ru\/post\/461567\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\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\" src=\"https:\/\/habrastorage.org\/webt\/gr\/ue\/1m\/grue1mys5l7b9rieubqlrxu5jfo.png\"><\/p>\n<p>  SQL (\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. <a href=\"https:\/\/ru.wikipedia.org\/wiki\/SQL\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435\u2026 <\/a><\/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 <a href=\"https:\/\/www.google.com\/search?q=SQL\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432<\/a>.<br \/>  \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.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-292774","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=292774"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/292774\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=292774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=292774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=292774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}