当前位置:网站首页>第三章 复杂一点的查询
第三章 复杂一点的查询
2022-07-23 08:35:00 【长沙的沙】
Q1
CREATE VIEW ViewPractice5_1(product_type, sale_price, regist_date)
AS
SELECT product_type, sale_price,regist_date
FROM product
WHERE regist_date = "2009-09-20" and sale_price>=1000;
Q2
SQL 错误 [1423] [HY000]: Field of view 'shop.viewpractice5_1' underlying table doesn't have a default value
还是因为视图的定义,视图只是原表的一个窗口,所以它修改也只能修改透过窗口能看到的内容。
Q3
SELECT product_id,
product_name,
sale_price,
(SELECT AVG(sale_price)
FROM product) AS avg_price
FROM product;
Q4
SELECT product_id, product_name, product_type, sale_price,
(SELECT AVG(sale_price)
FROM product AS p2
WHERE p1.product_type=p2.product_type
GROUP BY product_type) AS sale_price_all
FROM product AS P1
Q5
运算或者函数中含有 NULL 时,结果全都会变为NULL .
Q6
运行结果1:返回purchase_price结果不为500,2800,5000,且不为NULL 的行。
运行结果2:返回为空。就是上题提到的运算或函数中含有 NULL 时,结果全都会变为NULL 。筛选含/不含NULL的项,用IS NULL或IS NOT NULL.
Q7
SELECT
SUM(CASE WHEN sale_price BETWEEN 0 AND 1000 THEN 1 ELSE 0 END) AS low_price,
SUM(CASE WHEN sale_price BETWEEN 1001 AND 3000 THEN 1 ELSE 0 END) AS mid_price,
SUM(CASE WHEN sale_price>3000 THEN 1 ELSE 0 END) AS high_price
FROM product;
边栏推荐
- 视觉与智能学习近期期刊阅读与相关知识学习
- Notes on the fourth day
- STM32 output sine wave +cubemx configuration +hal Library
- Aruba学习笔记05-配置架构- WLAN配置架构
- Pagehepler lost the pit of the original SQL order by condition
- Consensys Quorum Benchmark Test
- 全志F1C100S/F1C200S学习笔记(13)——LVGL移植
- STM32输出SPWM波,HAL库,cubeMX配置,滤波后输出1KHz正弦波
- Summary of different circulation modes and precautions in JS
- What level is the Core i7 1165g7 equivalent to? What grade does the i71165g7 belong to
猜你喜欢

npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead.

Pagehepler lost the pit of the original SQL order by condition

Notes on the seventh day

Surrounded Regions

How many processors is Tianji 820 equivalent to Xiaolong? How about Tianji 1100 equivalent to Xiaolong? How about Tianji 820

剑指offer19 正则表达式

Detailed explanation of knapsack problem

Offline data interoperability

买卖股票的最佳时机

初识并查集
随机推荐
剑指offer19 正则表达式
Is there a big gap between core i5 12490f and i5 12600K
UIScrollView(UICollectionView)禁止横向和竖向同时滑动
ArcGIS使用DEM数据划定汇水区具体步骤过程
Pagehepler lost the pit of the original SQL order by condition
子序列 --- 编辑距离
回文相关题目
Okrk3399 Development Board reserves i2c4 to mount EEPROM
Experience in developing large crawlers in requests Library
Sampling and data driven
解决使用bert encoder出现的一系列问题
canvas橡皮擦功能
ArcGIS uses DEM data to delineate the specific steps and processes of catchment area
全志F1C100S/F1C200S学习笔记(13)——LVGL移植
链表复习!
数据库连接池 & DBUtils
Interface
Consensys Quorum Benchmark Test
JS to obtain age through ID card
494. 目标和