Giter Site home page Giter Site logo

12.3's Introduction

Домашнее задание к занятию 12.3. «SQL. Часть 1» - `Мальцев Виктор


Задание 1

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

Ответ:

select DISTINCT district from sakila.address where district like 'K%a' and district not like '% %';

alt text


Задание 2

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

Ответ:

select * from sakila.payment where payment_date >= '20050615' and payment_date <'20050619' HAVING amount >'10';

alt text


Задание 3

Получите последние пять аренд фильмов.

Ответ:

SELECT * FROM sakila.rental ORDER BY rental_id DESC LIMIT 5; SELECT * FROM sakila.rental ORDER BY rental_date DESC LIMIT 5;

alt text alt text


Задание 4

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

Сформируйте вывод в результат таким образом:

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

Ответ:

SELECT customer_id, store_id, REPLACE (LOWER(first_name), 'll', 'pp'), LOWER(last_name), email, address_id, active, create_date, last_update FROM sakila.customer where active = '1' AND first_name in ('Kelly', 'Willie');

alt text

12.3's People

Contributors

vmmaltsev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.