简体   繁体   English

如何执行这个 mySQL 查询?

[英]How to execute this mySQL Query?

I just need help with this mySQL question.我只需要帮助解决这个 mySQL 问题。

"Our products supplied at a higher price and it has been decided to pass this cost on to our customers. Increase the price by 3% on all products. “我们的产品以更高的价格供应,我们决定将这笔成本转嫁给我们的客户。将所有产品的价格提高 3%。

Write a query that returns a list of all products, their original price, and an additional column that contains the new (increased) prices."编写一个查询,返回所有产品的列表、它们的原始价格以及包含新(增加的)价格的附加列。”

Now i know how to increase the price by 3% however how am i supposed to do the second part?现在我知道如何将价格提高 3% 但是我该怎么做第二部分?

尝试这个

SELECT Product, Price, Price * 1.03 as newprice From Tablename;

SELECT product_name, product_price, product_price * 1.03 as product_increased_price From products;

在上面的查询中,它实际执行的操作是通过将产品的旧价格乘以3%来获得产品的名称 (product_name)产品的旧价格 (product_price)产品的新价格 (product_increased_price)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM