我需要获取一列比某个列大一定百分比的行。
所以说我有两列:
InventoryLevel int
InventoryAlert int
我需要获取InventoryLevel
比InventoryAlert
大25%的所有行。
这可以在一个查询中完成所有操作吗?任何帮助将不胜感激!
答案 0 :(得分: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 :(得分:4)
SELECT *
FROM YourTable
WHERE InventoryLevel = 1.25*InventoryAlert -- Or Maybe >= ?