Skip to content

Домашняя работа №2#4

Open
DimaRus05 wants to merge 2 commits into
mainfrom
hw2
Open

Домашняя работа №2#4
DimaRus05 wants to merge 2 commits into
mainfrom
hw2

Conversation

@DimaRus05
Copy link
Copy Markdown
Owner

No description provided.

Comment thread hw2.sql

-- 6. Какая функция позволяет выполнить замену NULL значения на значимую величину?
-- COALESCE, NULLIF, CASE WHEN
SELECT COALESCE(NULL, 'value') AS coalesce_example;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NULLIF -????
CASE WHEN - это не функция, а выражение

Comment thread hw2.sql Outdated

-- 7. Какая функция (функции) позволяет получить:
-- a. Часть строки, удовлетворяющую заданной маске?
-- SUBSTRING, REGEXP_MATCH, REGEXP_REPLACE
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Где примеры применения еще двух функций?

Comment thread hw2.sql Outdated
SELECT LEFT('example string', 10) AS left_example;
-- c. Все символы справа, начиная с указанной позиции
-- RIGHT, SUBSTRING
SELECT RIGHT('example string', 6) AS right_example;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не верное использование второго аргумента

Comment thread hw2.sql Outdated

-- 8. Какая функция используется для округления числа до 2-х знаков после запятой?
-- ROUND, TRUNC, CAST
SELECT ROUND(123.4567, 2) AS round_example;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пример cast -???

Comment thread hw2.sql Outdated
UPPER(SUBSTRING('строковые' FROM 1 FOR 1)) || SUBSTRING('строковые' FROM 2) || ' ' ||
UPPER(SUBSTRING('функции' FROM 1 FOR 1)) || SUBSTRING('функции' FROM 2) || ' ' ||
UPPER(SUBSTRING('PostgreSQL' FROM 1 FOR 1)) || SUBSTRING('PostgreSQL' FROM 2)
AS initcap_string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хочу увидеть логическое решение

Comment thread hw2.sql Outdated
-- c. Замените в массиве элемент sqlserver на postgres
SELECT ARRAY_REPLACE(ARRAY['sql', 'sqlserver', 'database', 'plsql'], 'sqlserver', 'postgres') AS replaced_array;
-- d. Верните из полученного массива последний элемент
SELECT (ARRAY_REPLACE(ARRAY['sql', 'sqlserver', 'database', 'plsql'], 'sqlserver', 'postgres'))[4] AS last_element;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разве сказано вернуть 4-й элемент? Вернуть последний!!!

Comment thread hw2.sql
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Необходимо внести исправления в соответствии с комментариями.

@pagaf
Copy link
Copy Markdown
Collaborator

pagaf commented Sep 27, 2025

Все ок!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants