John
John

Reputation: 33

Trying to compare two columns that are numbers

I'm trying to output the ones where the Units on Stock is less than the Units on Order. I'm trying to output the name, products on stock.

Here is the SQL statement:

SELECT ProductName, UnitsOnOrder, UnitsInStock 
FROM Product 
WHERE (SELECT UnitsInStock FROM Product) < (SELECT UnitsOnOrder);

Upvotes: 0

Views: 44

Answers (1)

A. Kojen
A. Kojen

Reputation: 152

If all of the attributes are in the Product table then I think this should work:

SELECT ProductName, UnitsInStock
FROM Product 
WHERE UnitsInStock < UnitsOnOrder

Upvotes: 2

Related Questions