jyoseph
jyoseph

Reputation: 5455

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:

I need to get all rows where the InventoryLevel is 25% greater than the InventoryAlert.

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

Upvotes: 3

Views: 5843

Answers (2)

Martin Smith
Martin Smith

Reputation: 453008

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

Upvotes: 7

Lamak
Lamak

Reputation: 70638

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

Upvotes: 4

Related Questions