Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create table Fornecedor(
- id_forn integer(10) not null,
- nome_forn varchar(24) not null,
- endereco_forn varchar(30) not null,
- cnpj_forn integer(18) not null,
- dataReceb_forn date not null,
- constraint id_forn_pk primary key (id_forn));
- create table Ingrediente(
- id_ingr integer(10) not null,
- nome_ingr varchar(24) not null,
- quantidade_ingr integer(5) not null,
- constraint id_ingr_pk primary key (id_ingr));
- create table Esfiha(
- id_esf integer(10) not null,
- nome_esf varchar(20) not null,
- sabor_esf varchar(16) not null,
- preco_esf integer(4.2) not null,
- constraint id_esf_pk primary key (id_esf));
- create table Funcionario(
- id_func integer(10) not null,
- nome_func varchar(24) not null,
- telefone_func integer(12) not null,
- doc_func integer(18) not null,
- email_func varchar(30) not null,
- endereco_func varchar(50) not null,
- constraint id_func_pk primary key (id_func));
- create table Cliente(
- id_cli integer(10) not null,
- nome_cli varchar(24) not null,
- telefone_cli integer(12) not null,
- endereco_cli varchar(50) not null,
- form_pagamento varchar(12) not null,
- constraint id_cli_pk primary key (id_cli));
- create table Venda(
- id_venda integer(10) not null,
- id_cliente integer(10) not null,
- id_funcionario integer(10) not null,
- id_esfiha integer(10) not null,
- preco integer(4.2) not null,
- dt_venda date not null,
- constraint venda_pk primary key(id_venda),
- constraint cli_fk foreign key (id_cliente) references Cliente(id_cli),
- constraint func_fk foreign key(id_funcionario) references Funcionario(id_func),
- constraint esf_fk foreign key(id_esfiha) references Esfiha(id_esf));
- insert into Fornecedor values(1, 'Gabriel', 'Avenida Paulista', '275', date '2018-11-03');
- insert into Fornecedor values(2, 'Pedro', 'Vila Carrão', '41410', date '2018-10-24');
- insert into Fornecedor values(3, 'Lucas', 'Sapopemba', '82820', date '2018-11-30');
- insert into Ingrediente values(1, 'Presunto', 30);
- insert into Ingrediente values(2, 'Queijo', 5);
- insert into Ingrediente values(3, 'Calabresa', 17);
- insert into Esfiha values(1, 'Especial', 'Tudo', 40);
- insert into Esfiha values(2, 'Padrao', 'Carne e Queijo', 5);
- insert into Esfiha values(3, 'Moda da Casa', 'Frango com Ched.', 35);
- insert into Funcionario values(1, 'Jose', 40028922, 329328, 'josepastel@hotmail.com', 'Rio de Janeiro');
- insert into Funcionario values(2, 'Wilson', 80416844, 95283, 'wilsonotario@gmail.com', 'Acre');
- insert into Funcionario values(3, 'Douglas', 6844324, 749043, 'douglas123@gmail.com', 'Rio Grande do Sul');
- insert into Cliente values(1, 'Josnildo', 123, 'Rua da Banana', 'Dinheiro');
- insert into Cliente values(2, 'Josefino', 246, 'Rua da Goiaba', 'Cartao');
- insert into Cliente values(3, 'Jorgescleyson', 4812, 'Rua do Abacate', 'Cheque');
- insert into Venda values(1, 1, 1, 1, 50, date '2018-12-01');
- insert into Venda values(2, 2, 2, 2, 80, date '2018-11-30');
- insert into Venda values(3, 3, 3, 3, 30, date '2018-09-17');
- select sabor_esf as Esfiha, preco_esf as Preço from Esfiha;
- select sabor_esf as Esfiha, preco_esf as Preço from Esfiha where preco_esf > 30;
- select nome_cli as Cliente, endereco_cli as Endereço from Cliente;
- select count(*) as Total_de_Vendas from Venda;
- select count(quantidade_ingr) as Total_de_Ingredientes from Ingrediente;
- select count(nome_func) as Total_de_Funcionarios from Funcionario;
- select count(nome_forn) as Total_de_Fornecedores from Fornecedor;
- select nome_forn as Fornecedor, cnpj_forn as CNPJ from Fornecedor;
- select nome_func as Funcionario, doc_func as Documento from Funcionario;
- select nome_func as Funcionario, endereco_func as Endereço from Funcionario where endereco_func = 'Rio de Janeiro';
- select nome_cli as Cliente, form_pagamento as Pagamento from Cliente where form_pagamento = 'Dinheiro';
- select nome_ingr as Ingrediente, quantidade_ingr as Quantidade from Ingrediente where nome_ingr = 'Presunto';
- select nome_ingr as Ingrediente, quantidade_ingr as Quantidade from Ingrediente where quantidade_ingr > 5;
- select nome_forn as Fornecedor, dataReceb_forn as Recebimento from Fornecedor where month(dataReceb_forn) = month(current_date()- interval 1 month);
- select Cliente.nome_cli as Cliente, sabor_esf as Sabor, sum(Esfiha.preco_esf)
- as Preço
- from Cliente
- inner join Esfiha on Cliente.id_cli = Esfiha.id_esf
- group by Cliente.nome_cli, sabor_esf;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement