当前位置:网站首页>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;
边栏推荐
猜你喜欢

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

優化華為雲服務器采用Key登陸

Okrk3399 Development Board reserves i2c4 to mount EEPROM

Tensor、Numpy、PIL格式转换以及图像显示

STM32 outputs SPWM wave, Hal library, cubemx configuration, and outputs 1kHz sine wave after filtering

剑指 Offer 46. 把数字翻译成字符串

Chicken and egg, products and Strategies
![[baiqihang] Niuer education helps colleges and universities visit enterprises, expand posts and promote employment](/img/41/6ef8f24732d9c75046ca8c55fd4841.png)
[baiqihang] Niuer education helps colleges and universities visit enterprises, expand posts and promote employment

JS texture style pie chart plug-in

How about the performance of Intel Celeron 7300? What level is it equivalent to
随机推荐
Summary of different circulation modes and precautions in JS
初识并查集
How can manual testing turn to automated testing? Byte 5 years of automation experience talk about
FPGA工程师如何进行复杂系统设计?
What level of rtx3070ti graphics card? What level of rtx3070ti graphics card? How about rtx3070ti graphics card
How about the performance of Intel Celeron 7305? What level is it equivalent to
JS to obtain age through ID card
Differences between Xiaomi 12s pro and Xiaomi 12pro Tianji version configuration comparison between the two
Talent evaluation Core i7 12850hx and i7 12700h which to choose
Design instantiation and connection
spotlight灯箱js插件全屏放大图片
-bash: ifconfig: command not found
What level is the Core i7 1165g7 equivalent to? What grade does the i71165g7 belong to
Optimize Huawei ECs to use key login
Quanzhi f1c100s/f1c200s learning notes (13) -- lvgl transplantation
shell跑的时候需要的需要了解命令
js日历样式饼图统计插件
webstrom ERROR in [eslint] ESLint is not a constructor
【模电复习——二极管】
Le shell a besoin de connaître les commandes