SQL - get rows where one column is a certain percentage greater than another
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 >= ?
精彩评论