阿里SQL学习笔记1——Task2

本笔记为阿里云天池龙珠计划SQL训练营的学习内容,链接为:https://tianchi.aliyun.com/specials/promotion/aicampsql;

内容会做在一个思维导图中——MySQL笔记 - GitMind

第二次作业

1.select product_name,regist_date
from product
where  regist_date  > “2009/4/28";

2.(1)返回整个表中价格为空值
(2)返回整个表中价格不为空的值
(3)返回整个表中价格大于空的值

3.select product_name,sale_price,purchase_price
from product
where sale_price >= purchase_price + 500;

select product_name,sale_price,purchase_price
from product > 100;
where sale_price - 500 >= purchase_price;

4.selcet product_name,product_type,sale_price * 0.9 - purchase_price as profit
from product
where sale_price * 0.9 - purchase_price > 100
AND ( product_type = '办公⽤品'
 OR product_type = '厨房⽤具');

5.where在group by 之后。
name不能用sum。
GROUP BY 字段( product_type )与 SELECT 字段不同( product_id )

6.select   product_type,sum(sale_price) ,sum(purchase_price)
from product
GROUP BY product_type
HAVING SUM(sale_price) > SUM(purchase_price) * 1.5;

7.时间排序倒序

你可能感兴趣的:(sql,数据库,database)