eliza555beth2002 commited on
Commit
8b36206
·
verified ·
1 Parent(s): 087c9b9

Upload dataset.json

Browse files

File with 7 examples of SQL query

Files changed (1) hide show
  1. dataset.json +30 -0
dataset.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);Отсортировать книги так, чтобы они шли в алфавитном порядке жанров, а если в жанре несколько книг, то в обратном алфавитном порядке книг",
4
+ "output": "select BookName, BookGenre from Books order by BookGenre, BookName desc;"
5
+ },
6
+ {
7
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);Найти тиражи в книги с шифром 6, в котор��х число поступивших экземпляров меньше 10",
8
+ "output": "select * from Сirculation where NumReceivedCopies<10 and BookСipher=6;"
9
+ },
10
+ {
11
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);Найти издательства, в которых торговая наценка находится в диапазоне от 0.15 до 0.3333",
12
+ "output": "select * from PublishingHouse where TradeMargin between 0.1500 and 0.3333;"
13
+ },
14
+ {
15
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);На��ти авторов, ФИО которых оканчивается на -ов",
16
+ "output": "select * from Bookstore.Authors where AuthorFIO like '%ов';"
17
+ },
18
+ {
19
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);Подвести итоги в таблице тиражей: сколько всего тиражей, общее число поступивших экземпляров, минимальное и максимальное число непроданных экземпляров, средняя закупочная цена.",
20
+ "output": "select count(*) as СirculationCount, sum(NumReceivedCopies) as AllReceivedCopies, min(NumUnsoldCopies) as MinUnsoldCopies, max(NumUnsoldCopies) as MaxUnsoldCopies, avg(PurchasePrice) as AvgPurchasePrice from Сirculation;"
21
+ },
22
+ {
23
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);Найти все тиражи, в которых количество непроданных копий больше 3, отсортировать и сгруппировать по дате поступления, вывести при условии, что закупочная цена больше 110000",
24
+ "output": "select DeliveryDate, count(*) as Counts, sum(PurchasePrice) as Prices from Сirculation where NumUnsoldCopies>3 group by DeliveryDate having sum(PurchasePrice)>110000 order by DeliveryDate;"
25
+ },
26
+ {
27
+ "input": "\ncreate database Bookstore\n\ncreate table Authors(\nAuthorID integer not null primary key check(AuthorID>0),\nAuthorFIO varchar(40) not null\n);\n\ncreate table Books(\nCipher integer not null primary key check(Cipher>0),\nBookName varchar(4000) not null,\nBookTheme varchar(30) not null\ncheck(BookTheme in('Любовь','Дружба','Смерть','Общественные проблемы','Внутренние противоречия')),\nBookGenre varchar(15) not null\ncheck(BookGenre in('Роман','Поэма','Рассказ','Пьеса','Эпопея','Драма'))\n);\n\ncreate table PublishingHouse(\nPublishingHouseID integer not null primary key\ncheck(PublishingHouseID>0),\nPublishingHouseName varchar(1000) not null,\nTradeMargin decimal(5,4) default'0' not null check (TradeMargin>0 and TradeMargin<=100)\n);\n\ncreate table Circulation(\nCirculationID integer not null primary key check(CirculationID>0),\nDeliveryDate date not null,\nPurchasePrice decimal(18,4) default'1000.0000' not null check(PurchasePrice>0),\nNumReceivedCopies integer not null check(NumReceivedCopies>=0),\nNumUnsoldCopies integer not null check(NumUnsoldCopies>=0),\nBookCipher integer not null check(BookCipher>0),\nIDPublishingHouse int not null check(IDPublishingHouse>0),\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nforeign key(IDPublishingHouse) references PublishingHouse(PublishingHouseID) on update cascade,\ncheck(NumReceivedCopies>NumUnsoldCopies)\n);\n\ncreate table Cheque(\nChequeID integer not null primary key\ncheck(ChequeID>0),\nPurchaseDate date not null,\nCashierFIO varchar(40) not null\n);\n\ncreate table Wrote(\nIDAuthor integer not null check(IDAuthor>0),\nBookCipher integer not null check(BookCipher>0),\nforeign key(IDAuthor) references Authors(AuthorID) on update cascade,\nforeign key(BookCipher) references Books(Cipher) on update cascade,\nprimary key(IDAuthor,BookCipher)\n);\n\ncreate table Contains(\nIDCheque int not null check(IDCheque>0),\nIDCirculation int not null check(IDCirculation>0),\nBooksQuantity int not null check(BooksQuantity>0),\nforeign key(IDCheque) references Cheque(ChequeID) on update cascade,\nforeign key(IDCirculation) references Circulation(CirculationID) on update cascade,\nprimary key(IDCheque,IDCirculation)\n);Сделать суммирующую строку для жанра и темы книги, посчитать количество книг для каждой пары жанр-тема.",
28
+ "output": "select [BookTheme],[BookGenre], count(*) as Counts from [dbo].[Books] group by [BookTheme],[BookGenre] with rollup;"
29
+ }
30
+ ]