s

 avatar
anhhackta
mysql
a month ago
1.3 kB
2
Indexable
Never
select * 
from products;
select *
from customers;

SHOW INDEX FROM customers


CREATE VIEW customerView AS
SELECT customerName
FROM customers;


select * from customerView;


CREATE OR REPLACE VIEW customerView AS
SELECT customerName
FROM customers;


select * from payments;


create or replace view thongke as
select customerNumber,sum(amount), (amount * 0.05) as giamgia,count(amount) as solanmua, sum(amount - (amount * 0.05)) as conlai
from payments

where customerNumber In (
select customerNumber
from customers
where state ='CA'
)

group by customerNumber


order by conlai ASC;










select * from thongke;


delimiter//
create procedure thongsotrvao (nhap int)

begin
	select customerNumber,amount
	from payments
	where amount > nhap;
	
	
end//

delimiter;

call thongsotrvao (10000);

delimiter//

create procedure timkiem (in ten varchar(255),out sl  int)

begin
select customerNumber,contactFirstName,contactLastName,state,country,city
from customers
where contactFirstName = ten or contactLastName = ten;
select count(*) into sl from customers
where contactFirstName = ten or contactLastName = ten;

end//

delimiter;

	

drop PROCEDURE timkiem;

Leave a Comment