Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Available Inventory Report

0 Likes
1,139
  • SAP Managed Tags

I am trying to write a query where I can find out what items are in stock, after deducting the committed quantities.

This works:

SELECT TOP 10 T1.[ItemCode], ( T1.[OnHand] - T1.[IsCommited] ) as [AVAILABLE] FROM [OITM] T1 ORDER BY [AVAILABLE]

But if I try to add [AVAILABLE] to the where clause:

SELECT TOP 10 T1.[ItemCode], ( T1.[OnHand] - T1.[IsCommited] ) as [AVAILABLE] FROM [OITM] T1 WHERE [AVAILABLE] > '0'

it gives the error "Invalid Column Name." I have tried this several different ways, all without success.

Any help would be appreciated.

Thanks,

Seth

1 ACCEPTED SOLUTION
Read only

KonradZaleski
Active Contributor
1,029
  • SAP Managed Tags

You cannot use alias in the WHERE clause directly. Try this:

SELECT TOP 10 
  T1.[ItemCode], 
  ( T1.[OnHand] - T1.[IsCommited] ) as [AVAILABLE] 
FROM 
  [OITM] T1 
WHERE 
  ( T1.[OnHand] - T1.[IsCommited] )  > 0
3 REPLIES 3
Read only

KonradZaleski
Active Contributor
1,030
  • SAP Managed Tags

You cannot use alias in the WHERE clause directly. Try this:

SELECT TOP 10 
  T1.[ItemCode], 
  ( T1.[OnHand] - T1.[IsCommited] ) as [AVAILABLE] 
FROM 
  [OITM] T1 
WHERE 
  ( T1.[OnHand] - T1.[IsCommited] )  > 0
Read only

0 Likes
1,029
  • SAP Managed Tags

Perfect! Yeah, I should have thought of that.

Thanks,

Seth

Read only

0 Likes
1,029
  • SAP Managed Tags

Please accept my answer if problem has been solved.