The example to this question is better:
ID PName Ppurchased PSold PSellPrice AvgSellprice
1 Water 50 10 100 20
2 Water 40 20 200 100
3 Water 70 35 50 25
What i want to happen within the table or maybe on a different table is to add the AvgSellprice of all 3 together to where it will look like this in a table:
ID PName Ppurchased PSold PSellPrice AvgSellprice TotalSellPrice
1 Water 50 10 100 20 145
2 Water 40 20 200 100 145
3 Water 70 35 50 25 145
Or maybe a new table which i want to look like this:
ID PName TotalSellPrice
1 Water 145
I know i can get the TotalSellPrice from the query:
SELECT SUM(AvgSellprice) AS TotalSellPrice
FROM tablename
WHERE PName='Water'
Also i am using MSSQL 2005 if this may differ. Thanks for any help.Also within this table there are other entries that do not pertain to the water. They have different names which may complicate things a little, not to sure as i don't know how to write the code for this table.
No comments:
Post a Comment