[英]SQL - Select rows where one column is greater than other column on the same date
[英]SQL - get rows where one column is a certain percentage greater than another
我需要得到一列,其中一列比另一列高一定百分比。
所以說我有2列:
InventoryLevel int
InventoryAlert int
我需要獲得InventoryLevel
比InventoryAlert
大25%的所有行。
這可以在一個查詢中完成所有操作嗎? 任何幫助將不勝感激!
SELECT InventoryLevel,
InventoryAlert
FROM YourTable
WHERE InventoryLevel > 1.25 * InventoryAlert
/*Incorrect for stated question but meets clarification in comment
"InventoryLevel is any value greater than 25%, doesn't have to be exact. "*/
SELECT *
FROM YourTable
WHERE InventoryLevel = 1.25*InventoryAlert -- Or Maybe >= ?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.