Just so I don't come across as someone who lectures and then goes away: :)Your question was about how to calculate profit percentages by city. So, first think about how you will calculate profit.profit = sellprice - costprice
Then, profit percentage isprofit_percentage = (sellprice-costprice)*100.0/costprice
That is for a single item. If you sold a lot of different things, your profit percentage would be:(sum(sellprice)-sum(costprice))*100.0/sum(costprice)
You are just adding up how much money you made by selling all that stuff, subtracting the sum of all the monies you paid out and then calculating that profit as a percentage of your cost.So your SQL statement would beselect (sum(sellprice)-sum(costprice))*100.0/sum(costprice) from GS_SALES
Now that is the total profit percentage. What if you wanted to find the profit percentage by city? (Which is really what your question was). Just as I said in my previous post, it should be as simple as:select City, (sum(sellprice)-sum(costprice))*100.0/sum(costprice) as ProfitPercentagefrom GS_SALES group by City
But there is just one slight problem. GS_SALES just does not have the City as a column. So you need to join the customer table which has the column City. And that would beselect City, sum(sellprice)-sum(costprice))*100.0/sum(costprice) as ProfitPercentagefrom GS_SALES, GS_CUSTOMERwhere GS_CUSTOMER.CUSTID = GS_SALES.CUSTIDgroup by City
That should get you the answer. Now if you wanted to add other columns, or other sums, you can - but just remember the rules about grouping that I said earlier. You can round if you like, or you can choose not to. But, first get this right. Everything else can be built up on top of this.