SQL - 获取一列比某个列大一定百分比的行

jyo*_*eph 2 sql sql-server-2008

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

所以说我有2列:

  • InventoryLevel int
  • InventoryAlert int

我需要获得InventoryLevel比其大25%的所有行InventoryAlert.

这可以在一个查询中完成所有操作吗?任何帮助将不胜感激!

Mar*_*ith 7

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. "*/
Run Code Online (Sandbox Code Playgroud)