2011-09-13 33 views
2

我需要获取行的位置,其中一列的比例大于另一列的比例。SQL - 获取行,其中一列的比例大于另一列的比例

所以说我有2列:

  • InventoryLevel int
  • InventoryAlert int

我需要得到所有行InventoryLevelInventoryAlert大于25%。

是否有可能在一个查询中执行所有操作?任何帮助将不胜感激!

回答

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. "*/ 
+1

谢谢,我很欣赏伟大的答案(和精神力量);) – jyoseph

4
SELECT * 
FROM YourTable 
WHERE InventoryLevel = 1.25*InventoryAlert -- Or Maybe >= ? 
+0

+1这个问题不实说“增加了25%”而不是“更大的大于25%”作为我的回答似乎承担! –

+0

@马丁史密斯 - 是的,我不知道它应该是**完全**超过25%,或超过25% – Lamak

+0

好!去给这个镜头。如果InventoryLevel的值大于25%,则不必确切。 – jyoseph

相关问题