开发者

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

开发者 https://www.devze.com 2023-04-04 09:08 出处:网络
I need to get rows where one column is a certain percentage greater than another. So say I have 2 columns:

I need to get rows where one column is a certain percentage greater than another.

So say I have 2 columns:

  • InventoryLevel int
  • InventoryAlert int

I need to get all rows where the InventoryLevel is 25% greater than the In开发者_高级运维ventoryAlert.

Is that possible to do all in one query? Any help would be greatly appreciated!


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 >= ?
0

精彩评论

暂无评论...
验证码 换一张
取 消