Skip to content
Open

Sql #48

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
217d966
Add files via upload
AleksanderB5 Apr 13, 2024
b2e9e79
решение1
AleksanderB5 Apr 13, 2024
a688d93
решение2-3
AleksanderB5 Apr 13, 2024
73be07c
Add files via upload
AleksanderB5 Apr 19, 2024
748f227
Add files via upload
AleksanderB5 Apr 22, 2024
ce5c913
Add files via upload
AleksanderB5 May 5, 2024
06d98ea
Add files via upload
AleksanderB5 May 5, 2024
63afc68
Add files via upload
AleksanderB5 May 14, 2024
f3f38e0
err
AleksanderB5 May 19, 2024
b1f0a8c
f
AleksanderB5 May 24, 2024
8fd4333
f
AleksanderB5 May 24, 2024
32413fb
Add files via upload
AleksanderB5 May 24, 2024
5d92c19
f
AleksanderB5 May 24, 2024
7529730
f
AleksanderB5 May 24, 2024
93b9ac5
otk
AleksanderB5 Jun 8, 2024
701aa68
Add files via upload
AleksanderB5 Jun 8, 2024
353e202
otk
AleksanderB5 Jun 8, 2024
a47cac5
otk
AleksanderB5 Jun 8, 2024
550d249
resh
AleksanderB5 Jun 19, 2024
bad0bc5
resh
AleksanderB5 Jun 19, 2024
c3a67df
resh
AleksanderB5 Jun 19, 2024
924b67c
Add files via upload
AleksanderB5 Jul 6, 2024
8bcacb6
kesh1
AleksanderB5 Jul 6, 2024
d256cba
kesh1
AleksanderB5 Jul 6, 2024
c1f12ad
kesh1
AleksanderB5 Jul 6, 2024
f5bef34
elk1
AleksanderB5 Jul 10, 2024
d95128c
Add files via upload
AleksanderB5 Jul 10, 2024
f7797cb
elk1
AleksanderB5 Jul 10, 2024
8898d09
ddl
AleksanderB5 Jul 13, 2024
c0ff88f
Add files via upload
AleksanderB5 Jul 13, 2024
c4b6000
ddl
AleksanderB5 Jul 13, 2024
00b8960
ddl
AleksanderB5 Jul 13, 2024
645ba95
Add files via upload
AleksanderB5 Jul 15, 2024
ecc33c0
sql
AleksanderB5 Jul 15, 2024
8800a47
Delete фото/1 sql.png
AleksanderB5 Jul 15, 2024
76e3db5
Add files via upload
AleksanderB5 Jul 15, 2024
04c02be
sql
AleksanderB5 Jul 15, 2024
7a5f8f7
sql
AleksanderB5 Jul 15, 2024
0e9deb0
sql
AleksanderB5 Jul 15, 2024
5c2db00
Add files via upload
AleksanderB5 Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 49 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,77 @@
# Домашнее задание к занятию "`Название занятия`" - `Фамилия и имя студента`
# Домашнее задание к занятию "`SQL. Часть 1`" - `Блинов А.С.`

# Домашнее задание к занятию «SQL. Часть 1»

### Инструкция по выполнению домашнего задания

1. Сделайте `fork` данного репозитория к себе в Github и переименуйте его по названию или номеру занятия, например, https://github.com/имя-вашего-репозитория/git-hw или https://github.com/имя-вашего-репозитория/7-1-ansible-hw).
2. Выполните клонирование данного репозитория к себе на ПК с помощью команды `git clone`.
3. Выполните домашнее задание и заполните у себя локально этот файл README.md:
- впишите вверху название занятия и вашу фамилию и имя
- в каждом задании добавьте решение в требуемом виде (текст/код/скриншоты/ссылка)
- для корректного добавления скриншотов воспользуйтесь [инструкцией "Как вставить скриншот в шаблон с решением](https://github.com/netology-code/sys-pattern-homework/blob/main/screen-instruction.md)
- при оформлении используйте возможности языка разметки md (коротко об этом можно посмотреть в [инструкции по MarkDown](https://github.com/netology-code/sys-pattern-homework/blob/main/md-instruction.md))
4. После завершения работы над домашним заданием сделайте коммит (`git commit -m "comment"`) и отправьте его на Github (`git push origin`);
5. Для проверки домашнего задания преподавателем в личном кабинете прикрепите и отправьте ссылку на решение в виде md-файла в вашем Github.
6. Любые вопросы по выполнению заданий спрашивайте в чате учебной группы и/или в разделе “Вопросы по заданию” в личном кабинете.

Желаем успехов в выполнении домашнего задания!

### Дополнительные материалы, которые могут быть полезны для выполнения задания

1. [Руководство по оформлению Markdown файлов](https://gist.github.com/Jekins/2bf2d0638163f1294637#Code)
1. Сделайте fork [репозитория c шаблоном решения](https://github.com/netology-code/sys-pattern-homework) к себе в Github и переименуйте его по названию или номеру занятия, например, https://github.com/имя-вашего-репозитория/gitlab-hw или https://github.com/имя-вашего-репозитория/8-03-hw).
2. Выполните клонирование этого репозитория к себе на ПК с помощью команды `git clone`.
3. Выполните домашнее задание и заполните у себя локально этот файл README.md:
- впишите вверху название занятия и ваши фамилию и имя;
- в каждом задании добавьте решение в требуемом виде: текст/код/скриншоты/ссылка;
- для корректного добавления скриншотов воспользуйтесь инструкцией [«Как вставить скриншот в шаблон с решением»](https://github.com/netology-code/sys-pattern-homework/blob/main/screen-instruction.md);
- при оформлении используйте возможности языка разметки md. Коротко об этом можно посмотреть в [инструкции по MarkDown](https://github.com/netology-code/sys-pattern-homework/blob/main/md-instruction.md).
4. После завершения работы над домашним заданием сделайте коммит (`git commit -m "comment"`) и отправьте его на Github (`git push origin`).
5. Для проверки домашнего задания преподавателем в личном кабинете прикрепите и отправьте ссылку на решение в виде md-файла в вашем Github.
6. Любые вопросы задавайте в чате учебной группы и/или в разделе «Вопросы по заданию» в личном кабинете.

Желаем успехов в выполнении домашнего задания.

---

Задание можно выполнить как в любом IDE, так и в командной строке.

### Задание 1

`Приведите ответ в свободной форме........`
Получите уникальные названия районов из таблицы с адресами, которые начинаются на “K” и заканчиваются на “a” и не содержат пробелов.

1. `Заполните здесь этапы выполнения, если требуется ....`
2. `Заполните здесь этапы выполнения, если требуется ....`
3. `Заполните здесь этапы выполнения, если требуется ....`
4. `Заполните здесь этапы выполнения, если требуется ....`
5. `Заполните здесь этапы выполнения, если требуется ....`
6.
### Решение 1

```
Поле для вставки кода...
....
....
....
....
```
![Скриншот-1](https://github.com/AleksanderB5/sys-pattern-homework-8-2/blob/sql/фото/1%20sql.png)

`При необходимости прикрепитe сюда скриншоты
![Название скриншота 1](ссылка на скриншот 1)`
### Задание 2

Получите из таблицы платежей за прокат фильмов информацию по платежам, которые выполнялись в промежуток с 15 июня 2005 года по 18 июня 2005 года **включительно** и стоимость которых превышает 10.00.

---
### Решение 2

### Задание 2
![Скриншот-2](https://github.com/AleksanderB5/sys-pattern-homework-8-2/blob/DDL/DML/фото/2%20sql.png)

`Приведите ответ в свободной форме........`
### Задание 3

1. `Заполните здесь этапы выполнения, если требуется ....`
2. `Заполните здесь этапы выполнения, если требуется ....`
3. `Заполните здесь этапы выполнения, если требуется ....`
4. `Заполните здесь этапы выполнения, если требуется ....`
5. `Заполните здесь этапы выполнения, если требуется ....`
6.
Получите последние пять аренд фильмов.

```
Поле для вставки кода...
....
....
....
....
```
### Решение 3

`При необходимости прикрепитe сюда скриншоты
![Название скриншота 2](ссылка на скриншот 2)`
![Скриншот-3](https://github.com/AleksanderB5/sys-pattern-homework-8-2/blob/DDL/DML/фото/3%20sql.png)

### Задание 4

---
Одним запросом получите активных покупателей, имена которых Kelly или Willie.

### Задание 3
Сформируйте вывод в результат таким образом:
- все буквы в фамилии и имени из верхнего регистра переведите в нижний регистр,
- замените буквы 'll' в именах на 'pp'.

`Приведите ответ в свободной форме........`
### Решение 4

1. `Заполните здесь этапы выполнения, если требуется ....`
2. `Заполните здесь этапы выполнения, если требуется ....`
3. `Заполните здесь этапы выполнения, если требуется ....`
4. `Заполните здесь этапы выполнения, если требуется ....`
5. `Заполните здесь этапы выполнения, если требуется ....`
6.
![Скриншот-4](https://github.com/AleksanderB5/sys-pattern-homework-8-2/blob/DDL/DML/фото/4%20sql.png)

```
Поле для вставки кода...
....
....
....
....
```
## Дополнительные задания (со звёздочкой*)
Эти задания дополнительные, то есть не обязательные к выполнению, и никак не повлияют на получение вами зачёта по этому домашнему заданию. Вы можете их выполнить, если хотите глубже шире разобраться в материале.

`При необходимости прикрепитe сюда скриншоты
![Название скриншота](ссылка на скриншот)`
### Задание 5*

### Задание 4
Выведите Email каждого покупателя, разделив значение Email на две отдельных колонки: в первой колонке должно быть значение, указанное до @, во второй — значение, указанное после @.

### Решение 5

![Скриншот-5](https://github.com/AleksanderB5/sys-pattern-homework-8-2/blob/DDL/DML/фото/5%20sql.png)

### Задание 6*

Доработайте запрос из предыдущего задания, скорректируйте значения в новых колонках: первая буква должна быть заглавной, остальные — строчными.

### Решение 6

`Приведите ответ в свободной форме........`

1. `Заполните здесь этапы выполнения, если требуется ....`
2. `Заполните здесь этапы выполнения, если требуется ....`
3. `Заполните здесь этапы выполнения, если требуется ....`
4. `Заполните здесь этапы выполнения, если требуется ....`
5. `Заполните здесь этапы выполнения, если требуется ....`
6.

```
Поле для вставки кода...
....
....
....
....
```

`При необходимости прикрепитe сюда скриншоты
![Название скриншота](ссылка на скриншот)`
![Скриншот-6](https://github.com/AleksanderB5/sys-pattern-homework-8-2/blob/DDL/DML/фото/6%20sql.png)
Binary file added img/1-1Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/1-2Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/1P.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/1P2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/1Z2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-1Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-2Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-3Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-3Z2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2-4Z.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2P.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2P2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2P2-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/2Z2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3P1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3P2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/3P2-2.png
Binary file added img/3P2.png
Binary file added img/4.png
Binary file added img/4P.png
Binary file added img/4Z2.png
Binary file added img/5P.png
Binary file added img/GL1-1.png
Binary file added img/GL1-2.png
Binary file added img/GL2-1.png
Binary file added img/GL2-2.png
Binary file added img/отк 1.png
Binary file added img/отк 2.png
Binary file added img/отк 3.png
28 changes: 28 additions & 0 deletions файлы/aleks
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.odCdAu/crontab installed on Fri May 24 17:35:53 2024)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command

0 0 * * * /home/aleks/rsync.sh
14 changes: 14 additions & 0 deletions файлы/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

IP=192.168.1.25 # ip адрес сервера
PORT=80 # порт веб сервера
HTML_FILE=/var/www/html/index.nginx-debian.html # путь к файлу стартовой страницы nginx

nc -z -w2 "$IP" "$PORT"
PORT_STATUS=$?

if [[ -f $HTML_FILE && $PORT_STATUS -eq 0 ]]; then
exit 0
else
exit 1
fi
20 changes: 20 additions & 0 deletions файлы/keepalived.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
vrrp_script check_script {
script "/etc/keepalived/check.sh"
interval 3
}

vrrp_instance VI_1 {
state MASTER
interface enp0s3
virtual_router_id 15
priority 255
advert_int 1

virtual_ipaddress {
192.168.1.115/24
}

track_script {
check_script
}
}
101 changes: 101 additions & 0 deletions файлы/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
terraform {
required_providers {
yandex = {
source = "yandex-cloud/yandex"
}
}
required_version = ">= 0.13"
}

provider "yandex" {
token = "y0_AgAAAAAB_Ql0AATuwQAAAAEA-RZjAABYAl8cLURFdJHWrogcv0WPoAtvJA"
cloud_id = "b1gtad7flabggbsbotg9"
folder_id = "b1ggulh78qigp1u640bn"
zone = "ru-central1-a"
}
resource "yandex_compute_instance" "vm" {
count = 2
name = "vm${count.index}"


resources {
core_fraction = 20
cores = 2
memory = 2
}

boot_disk {
initialize_params {
image_id = "fd8a67rb91j689dqp60h"
}
}

network_interface {
subnet_id = yandex_vpc_subnet.subnet-1.id
nat = true
}

metadata = {
user-data = "${file("./meta.yaml")}"
}

}
resource "yandex_vpc_network" "network-1" {
name = "network1"
}

resource "yandex_vpc_subnet" "subnet-1" {
name = "subnet1"
zone = "ru-central1-a"
network_id = yandex_vpc_network.network-1.id
v4_cidr_blocks = ["192.168.10.0/24"]
}

resource "yandex_lb_target_group" "target-1" {
name = "target-1"

target {
subnet_id = yandex_vpc_subnet.subnet-1.id
address = yandex_compute_instance.vm[0].network_interface.0.ip_address
}

target {
subnet_id = yandex_vpc_subnet.subnet-1.id
address = yandex_compute_instance.vm[1].network_interface.0.ip_address
}

}

resource "yandex_lb_network_load_balancer" "lb-1" {
name = "lb1"
listener {
name = "listener"
port = 80
external_address_spec {
ip_version = "ipv4"
}
}
attached_target_group {
target_group_id = yandex_lb_target_group.target-1.id
healthcheck {
name = "http"
http_options {
port = 80
path = "/"
}
}
}
}

output "internal_ip_address_vm-0" {
value = yandex_compute_instance.vm[0].network_interface.0.ip_address
}
output "external_ip_address_vm-0" {
value = yandex_compute_instance.vm[0].network_interface.0.nat_ip_address
}
output "internal_ip_address_vm-1" {
value = yandex_compute_instance.vm[1].network_interface.0.ip_address
}
output "external_ip_address_vm-1" {
value = yandex_compute_instance.vm[1].network_interface.0.nat_ip_address
}
26 changes: 26 additions & 0 deletions файлы/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#cloud-config
disable_root: true
timezone: Europe/Moscow
repo_update: true
apt:
preserve_sources_list: true
packages:
- nginx
runcmd:
- [ systemctl, nginx-reload ]
- [ systemctl, enable, nginx.service ]
- [ systemctl, start, --no-block, nginx.service ]
users:
- name: aleks
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCojDiK4NpR6TWyerAPOzUEuS4zd4yEi7GA396OKRgaGBP3Kii65Lqs+h7L9yhbozaUtLl/oasUN7JtqDtkttlt1pgZpJ3xUx45n3UlTTWC/EAPBgKA/S1wVSJDLA6GgaiRFkPWl3wuwi+Wz5Y6aHkBdd/PDsBNBJhMACR08u5JL3OuZ4hJsM1Gqs7XSoQVJeclLg4O/KtjDIUT8aPfZ6VUKH1niodCHNbFwNTrAkG5LJiZvYqRN5m8JFnTIUyl1rtz5Ik/LdKmiOSf+GDM2MnyVr9A1/D1HaOCl+79u3xo90G4VpbHpcHC8TAEWvh6QYFoYWKufG/G6V4bwHMP3w9aprWcpks0Gjc2OGJzMEkdapdurt2lUK+yeFYDwiEBqiMC/VELIkML4fQYgKZZZt2iYMw15WMrCzuaeXlmML8HrLp2dqo4nLUzEYpmEEz/QBwu+wOU/tOfl+CmYf1ZHdnGDMGtY6vq449I0DwAkC/4HZG0HcH6WiszvOxHRZtTIsc= aleks@BIG
users:
- name: aleks
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCojDiK4NpR6TWyerAPOzUEuS4zd4yEi7GA396OKRgaGBP3Kii65Lqs+h7L9yhbozaUtLl/oasUN7JtqDtkttlt1pgZpJ3xUx45n3UlTTWC/EAPBgKA/S1wVSJDLA6GgaiRFkPWl3wuwi+Wz5Y6aHkBdd/PDsBNBJhMACR08u5JL3OuZ4hJsM1Gqs7XSoQVJeclLg4O/KtjDIUT8aPfZ6VUKH1niodCHNbFwNTrAkG5LJiZvYqRN5m8JFnTIUyl1rtz5Ik/LdKmiOSf+GDM2MnyVr9A1/D1HaOCl+79u3xo90G4VpbHpcHC8TAEWvh6QYFoYWKufG/G6V4bwHMP3w9aprWcpks0Gjc2OGJzMEkdapdurt2lUK+yeFYDwiEBqiMC/VELIkML4fQYgKZZZt2iYMw15WMrCzuaeXlmML8HrLp2dqo4nLUzEYpmEEz/QBwu+wOU/tOfl+CmYf1ZHdnGDMGtY6vq449I0DwAkC/4HZG0HcH6WiszvOxHRZtTIsc= aleks@BIG
Binary file added фото/1 sql.png
Binary file added фото/1-1 ddl.png
Binary file added фото/1-1.png
Binary file added фото/1-2 ddl.png
Binary file added фото/1-2.png
Binary file added фото/1-3 ddl.png
Binary file added фото/1-4 ddl.png
Binary file added фото/1-sql2.png
Binary file added фото/1.png
Binary file added фото/2 sql.png
Binary file added фото/2-1.png
Binary file added фото/2-2.png
Binary file added фото/2-3.png
Binary file added фото/2-sql2.png
Binary file added фото/2.png
Binary file added фото/3 sql.png
Binary file added фото/3-sql2.png
Binary file added фото/3.png
Binary file added фото/4 sql.png
Binary file added фото/4-sql2.png
Binary file added фото/4.png
Binary file added фото/5 sql.png
Binary file added фото/5-sql2.png
Binary file added фото/6 sql.png
Binary file added фото/кеш2.png
Binary file added фото/кеш3.png
Binary file added фото/кэш1.png