Beruflich Dokumente
Kultur Dokumente
show databases;
use MySales;
show tables;
describe customers;
show tables;
describe customers;
show tables;
describe Orders;
describe OrderDetails;
--------------------------------------------Insert
Data-------------------------------------------------------
------------------------------------------- Select
---------------------------------------------------------
-----------------------------------------------------------------------------------
----------------
-----------------------------------------------------------------------------------
----------------
-----------------------------------------------------------------------------------
----------------
-----------------------------------------------------------------------------------
----------------
select * from customers
where city='Mumbai' or city='Pune';
-----------------------------------------------------------------------------------
----------------
-----------------------------------------------------------------------------------
----------------
select count(CustID),city
from customers
GROUP BY city
ORDER BY count(CustID) desc;
--------------------------------------------
Having-------------------------------------------------------
select count(CustID),city
from customers
GROUP BY city
having count(CustID) > 1;
select OrderID,sum(Qty)
from orderdetails
group by OrderID
having sum(Qty) > 5;
----------------------------------------------
Aliases-----------------------------------------------------
--------------------------------------------Union
---------------------------------------------------------
--------------------------------------------Views
---------------------------------------------------------
create view Customers_Name AS
select FirstName, LastName
from customers;
--------------------------------------------Sub
Queries-----------------------------------------------------
select * from customers
where CustID IN (select CustID from customers
where city = 'Mumbai');
--------------------------------------------------
create view BigOrderQty AS
select OrderID
from
orderdetails where Qty >= 5;