当前位置:网站首页>第三章 复杂一点的查询
第三章 复杂一点的查询
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;
边栏推荐
- The difference between rtx3080ti and 3090. Which one is more cost-effective, rtx3080ti or 3090
- JS realize random generation of UUID
- What level of rtx3070ti graphics card? What level of rtx3070ti graphics card? How about rtx3070ti graphics card
- 链下数据互操作
- Spark统计每天新增用户
- Pbootcms数据库转换教程(sqlite转mysql详细教程)
- Okrk3399 Development Board reserves i2c4 to mount EEPROM
- Description of test platform and hardware design
- Pagehepler lost the pit of the original SQL order by condition
- Tell you Web3.0 I understand
猜你喜欢

数据库连接池 & DBUtils

Pbootcms数据库转换教程(sqlite转mysql详细教程)

手工测试如何转向自动化测试?字节5年自动化经验浅谈一下...

求岛屿最大面积--深度优先搜索(染色法)

494. 目标和

spotlight灯箱js插件全屏放大图片

Changing the historical length of chart during LabVIEW operation

子序列 --- 编辑距离

How about the performance of Intel Celeron 7300? What level is it equivalent to

VK36N5D抗电源干扰/手机干扰 5键5通道触摸检测芯片防呆功能触摸区域积水仍可操作
随机推荐
The difference between rtx3080ti and 3090. Which one is more cost-effective, rtx3080ti or 3090
Is it risky and safe to open a mobile stock account?
JS realize random generation of UUID
Okrk3399 Development Board Reserved i2c4 Mounting EEPROM
将我理解的web3.0讲给你听
Shell实践:一键启动进程、关闭进程、查看进程状态
OKRK3399开发板预留I2C4挂载EEPROM
Find the maximum area of the island -- depth first search (staining method)
AppScan的安装与使用
antd form表单——重置方法不生效——基础积累——prop的重要性
Drag and drop----
Notes on the seventh day
Experience in developing large crawlers in requests Library
Surrounded Regions
STM32输出SPWM波,HAL库,cubeMX配置,滤波后输出1KHz正弦波
10年软件测试工程师经验,很茫然....
Differences between Xiaomi 12s pro and Xiaomi 12pro Tianji version configuration comparison between the two
OKRK3399開發板預留I2C4掛載EEPROM
js 实现通过身份证获取年龄
初识并查集