Загрузил Alexander

sapiens soluyions test

реклама
1.
Вопрос: Какое значение вернет sql скрипт?
CREATE TABLE subjects (
id INT,
name VARCHAR(100),
teacher VARCHAR(100),
cabinet INT
);
INSERT INTO subjects (Id, Name, Teacher, Cabinet)
VALUES
(1001, 'Алгебра', 'Чичкина Ольга Александровна', 431),
(1002, 'Биология', 'Андреева Анна Тимофеевна', 522),
(1003, 'Химия', 'Локтева Татьяна Александровна', 123),
(1004, 'Иностранный язык', 'Антоненко Елена Владимировна', 437),
(1005, 'География', 'Иванова Людмила Александровна', 501),
(1006, 'Физическая культура', 'Кривошея Тамара Яковлевна', 236),
(1007, 'Физика', 'Котляренко Людмила Александровна', 141);
CREATE TABLE diary (
id INT,
student VARCHAR(100),
mark INT,
subj_id INT,
date_mark DATE
);
INSERT INTO diary (Id, Student, Mark, Subj_id, Date_mark)
VALUES
(2001, 'Ансимова Елизавета Андреевна', 5, 1001, '2015-01-10'),
(2002, 'Беляев Матвей Артёмович', 4, 1000, '2015-01-10'),
(2003, 'Боленский Василий Борисович', 2, 1003,'2015-01-10'),
(2004, 'Фазуллина Дина Фанилевна', 4, 1004, '2015-01-10'),
(2005, 'Халитова Рената Булатовна', 5, 1009, '2015-01-10'),
(2006, 'Маслюков Дмитрий Владимирович', 3, 1007, '2015-01-10'),
(2007, 'Халитова Рената Булатовна', 4, 1005, '2015-01-10'),
(2008, 'Фазуллина Дина Фанилевна', 3, 1003, '2015-01-10'),
(2009, 'Халитова Рената Булатовна', 5, 1005, '2015-01-10'),
(2010, 'Беляев Матвей Артёмович', 2, 1004, '2015-01-10'),
(2011, 'Маслюков Дмитрий Владимирович', 3, 1004, '2015-01-10'),
(2012, 'Фазуллина Дина Фанилевна', 5, 1007, '2015-01-10'),
(2013, 'Боленский Василий Борисович', 4, 1002, '2015-01-10'),
(2014, 'Халитова Рената Булатовна', 5, 1002, '2015-01-10'),
(2015, 'Фазуллина Дина Фанилевна', 5, 1001, '2015-01-10'),
(2016, 'Маслюков Дмитрий Владимирович', 4, 1001, '2015-01-10'),
(2017, 'Ансимова Елизавета Андреевна', 4, 1005, '2015-01-10'),
(2018, 'Боленский Василий Борисович', 3, 1003, '2015-01-10'),
(2019, 'Ансимова Елизавета Андреевна', 5, 1007, '2015-01-10'),
(2020, 'Беляев Матвей Артёмович', 2, 1004, '2015-01-10');
SELECT char_length(dia.student)
FROM subjects AS sub RIGHT JOIN diary AS dia
ON sub.id = dia.subj_id
GROUP BY dia.student
HAVING avg(dia.mark) LIKE (SELECT min(av.avg_mark)
FROM (SELECT dia1.student, avg(dia1.mark) AS avg_mark
FROM subjects AS sub1 RIGHT JOIN diary AS dia1
ON sub1.id = dia1.subj_id
WHERE sub1.cabinet NOT LIKE '%4%'
GROUP BY dia1.student) AS av);
(Мой ответ: 19)
2.
Вопрос: Какое значение вернет sql скрипт?
SELECT SUM(b.trav_expens) AS SUM_TRAV_EXPENS
FROM employees AS e LEFT JOIN business_trip AS b
ON e.employ_id = b.employ_id
WHERE e.salary > 90000 AND b.dep_date >= '2015-06-01';
(Мой ответ: 151800)
3.
Вопрос: Какое значение вернет sql скрипт?
SELECT SUM(fact.quant)
FROM (SELECT
docid,
itemid,
SUM(CASE
WHEN status_type IN ('Приёмка на склад','Разгрузка','Складское действие','Поступление') AND
THEN 1
END) AS flag
FROM status_delivery
GROUP BY docid, itemid
) AS stat
LEFT JOIN deliveries AS fact
ON stat.docid = fact.docid
AND stat.itemid = fact.itemid
AND stat.flag = 4;
(Мой ответ: 44)
4.
Вопрос: Какое значение вернет sql скрипт?
SELECT (SELECT SUM(PRICE)
FROM INTERNET
WHERE PUR_DATE <= T1.PUR_DATE) COSTS
FROM INTERNET T1
ORDER BY IM, PUR_DATE
OFFSET 1 ROWS FETCH NEXT 1 ROWS ONLY;
(Мой ответ: 25200)
5.
Необходимые преобразования:
WITH T1 AS (SELECT SHOPS.SHOP FROM SHOPS JOIN WAREHOUSE
ON SUBSTRING(WAREHOUSE.ID, 5, 4) = SHOPS.SHOP)
UPDATE WAREHOUSE
SET WAREHOUSE =
CASE
WHEN WAREHOUSE.WAREHOUSE = '' AND SUBSTRING(WAREHOUSE.ID, 5, 4) IN (SELECT SHOP FROM
THEN (SELECT SUBSTRING(SHOPS.DOC_NUMBER, 11, 2) FROM SHOPS WHERE SUBSTRING(WAREHO
SHOPS.SHOP)
END,
DOCUMENT =
CASE
WHEN WAREHOUSE.DOCUMENT = '' AND SUBSTRING(WAREHOUSE.ID, 5, 4) IN (SELECT SHOP FROM
THEN (SELECT (SUBSTRING(SHOPS.DOC_NUMBER, 6, 7) + '-' + SUBSTRING(CAST(SHOPS.DAY AS CHA
SHOPS.SHOP)
END,
MONTH =
CASE
WHEN WAREHOUSE.MONTH = 0 AND SUBSTRING(WAREHOUSE.ID, 5, 4) IN (SELECT SHOP FROM T1)
THEN (SELECT (SUBSTRING(CAST(SHOPS.DAY AS CHAR), 6, 2)) FROM SHOPS WHERE SUBSTRING(WA
END
Вопрос: Какое значение вернет sql скрипт?
SELECT COUNT(WAREHOUSE) FROM WAREHOUSE
WHERE WAREHOUSE IS NOT NULL AND SUBSTRING(WAREHOUSE.DOCUMENT,
12, 2) >= 24;
(Мой ответ: 3)
6.
Вопрос: Какое значение вернет sql скрипт?
CREATE TABLE employees (
id INT,
name VARCHAR(50),
department VARCHAR(50),
salary INT
);
INSERT INTO Employees (Id, Name, Salary, department)
VALUES
(1, 'Ivanov', 100000, 'SAPIENS'),
(2, 'Petrov', 100000, 'SAPIENS'),
(3, 'Sidorov', 130000, 'TECHNOLOGIES'),
(4, 'Korotkov', 120000, 'TECHNOLOGIES'),
(5, 'Filev', 90000, 'SAPIENS'),
(6, 'Smirnov', 125000, 'REVOLT'),
(7, 'Godov', 125000, 'REVOLT') ;
SELECT (AVG(ROW_NUMBER) + SUM(RANK) + SUM(DENSE_RANK))
FROM (SELECT
DEPARTMENT
, SALARY
, ROW_NUMBER() OVER(PARTITION BY DEPARTMENT ORDER BY SALARY DESC) AS
'ROW_NUMBER'
, RANK() OVER(PARTITION BY DEPARTMENT ORDER BY SALARY DESC) AS 'RANK'
, DENSE_RANK() OVER(PARTITION BY DEPARTMENT ORDER BY SALARY DESC) AS 'DENSE_RANK'
FROM EMPLOYEES) AS T1
WHERE DEPARTMENT LIKE '%A__E%';
(Мой ответ: NULL)
Скачать