Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL to update column

 
Raj Ohadi
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table with following columns:

id(PK), name, score_1, score_2, score_3, rating

First I have the data for all columns EXCEPT rating. Then I want to update "rating" for each row using this rule

if (score_1 + score_2 + score_3) > 90: rating = A
if it > 80 but < 90 : rating =B
...

How to write this sql ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34681
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj,
You would need update statements. The easiest way to do this is to have one update statement for each letter grade. Try write an update statement for the first one and post here if you get stuck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic