簡體   English   中英

SQL - 獲取一列比某個列大一定百分比的行

[英]SQL - get rows where one column is a certain percentage greater than another

我需要得到一列,其中一列比另一列高一定百分比。

所以說我有2列:

  • InventoryLevel int
  • InventoryAlert int

我需要獲得InventoryLevelInventoryAlert大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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM