当前位置:网站首页>Chapter 3 complex query
Chapter 3 complex query
2022-07-23 14:28:00 【Sand in Changsha】
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 error [1423] [HY000]: Field of view 'shop.viewpractice5_1' underlying table doesn't have a default value
Or because of the definition of the view , The view is just a window of the original table , Therefore, it can only modify the content that can be seen through the window .
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
An operation or function contains NULL when , It all turns out to be NULL .
Q6
Running results 1: return purchase_price The result is not 500,2800,5000, And not for NULL The line of .
Running results 2: Return to empty . The operation or function mentioned above contains NULL when , It all turns out to be NULL . Screening contains / Not included NULL The item , use IS NULL or 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;
边栏推荐
- Fabric. JS basic brush
- Rtx3080 is equivalent to GTX. What kind of graphics card is rtx3080? What level is rtx3080
- 第2章 基础查询与排序
- How about the performance of Intel Celeron 7305? What level is it equivalent to
- How many processors is Tianji 1100 equivalent to snapdragon? How about Tianji 1100 equivalent to snapdragon
- Surrounded Regions
- Pbootcms数据库转换教程(sqlite转mysql详细教程)
- Uiscrollview (uicollectionview) prohibits horizontal and vertical sliding at the same time
- Fastadmin changes the pop-up size of the default table button
- Drag and drop----
猜你喜欢

10年软件测试工程师经验,很茫然....

STM32输出正弦波+cubeMX配置+HAL库

完全背包!

How about Celeron n5095 Processor? What is the equivalent level of Intel n5095 core display

FPGA工程师如何进行复杂系统设计?

338. 比特位计数

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

494. 目标和

剑指offer19 正则表达式

Tensor, numpy, PIL format conversion and image display
随机推荐
Rtx3080ti and rtx3080 gap 3080 and 3080ti parameter comparison
数据库连接池 & DBUtils
基金开户网上办理是否安全?谁给解答一下
canvas橡皮擦功能
[review of analog electricity - diode]
拖拽----
npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead.
ArcGIS使用DEM数据划定汇水区具体步骤过程
股票炒股开户风险性大吗,安全吗?
力扣142题:环形链表2
激励发生器、监测器
【FLink】FLink Hash collision on user-specified ID “opt“. Most likely cause is a non-unique ID
剑指 Offer 46. 把数字翻译成字符串
【FLink】FLink Hash collision on user-specified ID “opt“. Most likely cause is a non-unique ID
AppScan的安装与使用
太平洋大西洋水流问题
Tell you Web3.0 I understand
【附下载】值得收藏的几款渗透测试常用的脚本
Cool code rain dynamic background registration page
第4章 集合运算