Operator usage score in PTA product table query statement 4

This topic requires writing SQL statements,

In the sh_goods table, query the value of the 5-star favorable product inventory after the increase of 850, and the price of these products after the 25% discount promotion. The query result display fields are set according to the output sample.

Tip: Please use the SELECT statement to answer.

Table Structure:

CREATE TABLE sh_goods (
  id INT  PRIMARY KEY,                         --商品id
  category_id INT  NOT NULL DEFAULT 0 ,        -- 商品分类id
  name VARCHAR(120) NOT NULL,                  --商品名称
  keyword VARCHAR(255) NOT NULL,               -- 关键词编号
  content TEXT NOT NULL ,                      --商品详情
  price DECIMAL(10, 2)  NOT NULL DEFAULT 0 ,   --价格
  stock INT  NOT NULL DEFAULT 0,               -- 库存
  score DECIMAL(3, 2)  NOT NULL DEFAULT 0 ,    -- 用户评分
  comment_count INT  NOT NULL DEFAULT 0        -- 评论数量
) ;

table sample

sh_goods table:

Sample output:

Code length limit 16 KB

Time limit 400 ms

Database SQL Server

The result output requires a strict comparison of the order and data

select name, price old_price, stock old_stock, price*0.75 new_price, stock+850 new_stock
from sh_goods
where score = 5

Guess you like

Origin blog.csdn.net/weixin_70206677/article/details/129360276