Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi. its been a long time since i used sql . currently i am looking for a select statement that would calculate values of two columns(price, discount) in the same table(items) but i want the result to be stored at a different table(buy) on the column discount price. an example would help. thank you
Posted

1 solution

Here is a simple example of the syntax needed for your query:

SQL
INSERT INTO dbo.Buy(DiscountPrice)
SELECT Discount * Price
FROM dbo.Items


This will insert a new row into the Buy table for each row in the Items table. This may not be exactly what you are looking for. You might need to do an UPDATE statement instead of an INSERT if you are trying to update existing rows in the Buy table.
 
Share this answer
 
Comments
morojele 2-Jun-12 18:44pm    
this is good enough thanx
Tim Corey 2-Jun-12 18:49pm    
Great. Glad I could help. Please mark the solution as accepted so others know the question has been answered. Thanks.

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