
select cust_id from Customers;

select distinct prod_id from OrderItems;

select * from Customers;

小小的脑袋大大的疑惑,按字母排?order by
select cust_name from Customers order by cust_name desc;

id正序,订单日期倒序
select cust_id,order_num from Orders order by cust_id,order_date desc;

select quantity,item_price from OrderItems order by quantity desc,item_price desc;

select vend_name from Vendors order by vend_name desc;

select prod_id,prod_name from Products where prod_price = 9.49;

select prod_id,prod_name from Products where prod_price >= 9;

两种都行
select prod_name,prod_price from Products where prod_price between 3 and 6;
select prod_name,prod_price from Products where prod_price >=3 and prod_price <=6;

select distinct order_num from OrderItems where quantity >=100;

select vend_name from Vendors where vend_country = 'USA' and vend_state = 'CA';

select order_num,prod_id,quantity from OrderItems where quantity>=100 and (prod_id = 'BR01' | prod_id = 'BR01'|prod_id = 'BR01');
select order_num,prod_id,quantity from OrderItems where quantity>=100 and prod_id in ( 'BR01' ,'BR02','BR03');

select prod_name,prod_price from Products where prod_price >=3 and prod_price <=6 order by prod_price;

SELECT vend_name
FROM Vendors
WHERE vend_country = 'USA' AND vend_state = 'CA' ORDER BY vend_name ;

select prod_name,prod_desc from Products where prod_desc like '%toy';

select prod_name,prod_desc
from Products
where prod_desc not like '%toy';

select prod_name,prod_desc
from Products prod_desc
where prod_desc like '%toy' and prod_desc like '%carrots%';

select prod_name,prod_desc
from Products prod_desc
where prod_desc like '%toy%carrots%';

select
vend_id,
vend_name as vname,
vend_address as vaddress,
vend_city as vcity
from Vendors
order by vend_name ;

select prod_id,prod_price,prod_price * 0.9 as sale_price from Products;