File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes SQL to update column Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL to update column" Watch "SQL to update column" New topic

SQL to update column

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
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
internet detective

Joined: May 26, 2003
Posts: 30116

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.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: SQL to update column
Similar Threads
Multiple Actions issue in JSF
Using JSTL Data Displayed In Browser Is Getting Fixed To 24576 Bytes(24 KB)
Returning A List Of Variables From A Folder Of Documents And Returning Them Into A New Document
Repeatable SQL
JSP attendance management project error