Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table that keeps the stock. What I want to do is reduce the stock quantity by a % and then calculate the remaining stock. How would I do this as an SQL Statement? The table I have is called Stock and the fields in it are StockID, product, quantity and Price.
Posted
Updated 13-Dec-11 2:32am
v5

1 solution

Why not just something like this:
SQL
SELECT WarehouseID, FishType, (Stock * 0.7), Price FROM Warehouse;

Good luck!
 
Share this answer
 
Comments
programmer1234 12-Dec-11 8:17am    
That works, but how would I show the new price of the new stock?
fjdiewornncalwe 12-Dec-11 9:32am    
Price * (Stock * 0.7)
E.F. Nijboer 12-Dec-11 14:47pm    
You can't name subexpressions in your query because they aren't shown in the end result. Remove "AS NewStock" and it will wortk. You would need to include both expressions separately in your query. Something like:
(Stock * 0.7) AS NewStock, (FishPrice * (Stock * 0.7)) AS NewPrice
[no name] 12-Dec-11 20:37pm    
5ed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900