Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Geeks

SQL
Combo  Sizes   Ratio
  1     56       1
  1     62       2
  1     68       2
  1     74       1 
  1     80       1
  2     62       1
  2     68       2
  2     74       2
  2     80       1


I've a checkbox which shows 1&2 in UI. When I select both 1 and 2, I should get result like this

SQL
Sizes   Ratio
 56       1
 62       3
 68       4
 74       4
 80       2

which should add the ratio according to the sizes. I stuck up with logic. Can anyone help me with this logic?
Posted

1 solution

Try:
SQL
SELECT Sizes, SUM(Ratio) AS Ratio 
FROM MyTable
GROUP BY Sizes
 
Share this answer
 

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