Программирование >>  Руководство по sql 

1 ... 98 99 100 [ 101 ] 102 103 104 105


values(19,7896,Х999, 02/21/88) go

insert into sales

values!10,7896,QQ2299, 10/28/87) go

insert into sales

values(11,7896,TQ456, 12/12/87) go

insert into sales

values(12,8042,QA879.1, 5/22/87) go

insert into sales

values(13,7066,A2976, 5/24/87) go

insert into sales

values{14,7131,P3087a, 5/29/87) go

insert into sales

values(15,7067,P2121, 6/15/87) go

insert into salesdetails

values(l, 75, 75,PS2091, 9/15/85)

insert into salesdetails

values(2, 10, 10,PS2091, 9/15/85)

insert into salesdetails

values(3, 20, 720,PS2091, 9/18/85)

insert into salesdetails

values(4, 25, 20,MC3021, 9/18/85)

insert into salesdetails

values(5, 15, 15,MC3021, 9/14/85)

insert into salesdetails

values(6, 10, 3,BU1032, 9/22/85)

insert into salesdetails

values(7, 3, 3,PS2091, 9/20/85)

insert into salesdetails

values(8, 5, 5,BU1032, 9/14/85)

insert into salesdetails

values(9, 25, 5,BUllll, 03/2ff/88)

insert into salesdetails

values(19, 35, 35,BU2075, 03/15/88)

insert into salesdetails

values(10, 15, 15,BU7832, 10/29/87)



insert into salesdetails

values{ll, 10, 1Q,MC2222, 1/12/88; go

insert into salesdetails

values(12, 30, 30,PC1035, 5/24/87; go

insert into salesdetails

values(13, 50, 50,PC8888, 5/24/87; go

insert into salesdetails

values(14, 20, 20,PS1372, 5/29/87 go

insert into salesdetails

values(14, 25, 25,PS2106, 4/29/87 go

insert into salesdetails

values(14, 15, 10,PS3333, 5/29/87;

insert into salesdetails values(14, 25, 25,PS7777, 6/13/87; go

insert into salesdetails values(15, 40, 40,TC3218, 6/15/87; go

insert into salesdetails values{15, 20, 20,TC4203, 5/30/87; go

insert into salesdetails values(15, 20, 10,TC7777, 6/17/87; go

drop view titleview go

create view titleview as

select title, au ord, au lname,

price, ytd sales, pub id

from authors, titles, titleauthors

where authors.au id = titleauthors.au id

and titles.title id = titleauthors.title id

drop view oaklanders go

create view oaklanders as

select au fname, au lname, title from authors, titles, titleauthors where authors.au id = titleauthors.au id

and titles.title id = titleauthors.title id

and city = Oakland

drop view books go

create view books



select titles.title id, au ord, au lname, au fname from authors, titles, titleauthors where authors.au id=titleauthors.au id and titles.title id = titleauthors.title id

drop view royaltychecks go

create view royaltychecks as

select au lname, au fname,

sum(price*ytd sales*royalty*royaltyshare) as Total Income from authors, titles, titleauthors, roysched where authors.au id=titleauthors.au id

and titles.title id = titleauthors.title id

and titles.title id = roysched.title id

and ytd sales between lorange and hirange group by au lname, au fname go

drop view currentinfo go

create view currentinfo (PUBjf, TYPE, INCOME, AVG PRICE, AVG SALES)

select pub id, type, sum(price * ytd sales),

avg(price), avg(ytd sales) from titles group by pub id, type go

drop view hiprice go

create view hiprice as

select * from titles where price > $15 and advance > $5000

drop view cities go

create view cities (Author, Authorcity, Pub, Pubcity) as

select au lname, authors.city, pub name, publishers.city

from authors, publishers

where authors.city = publishers.city

drop view highaverage go

create view highaverage as

select authors.au id, titles.title id, pub name, price from authors, titleauthors, titles, publishers where authors.au id = titleauthors.au id and



1 ... 98 99 100 [ 101 ] 102 103 104 105

© 2006 - 2024 pmbk.ru. Генерация страницы: 0
При копировании материалов приветствуются ссылки.
Яндекс.Метрика