Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:59:46+00:00 2026-06-12T00:59:46+00:00

This is my table. What I need to do is create a CASE WHEN

  • 0

This is my table.

What I need to do is create a CASE WHEN UPDATE Query to update

  • CurrentCredit +1 if 1-15

  • CurrentCredit +2 if 16-30

  • CurrentCredit x.10 and round up if >=31

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:59:47+00:00Added an answer on June 12, 2026 at 12:59 am

    Have a look at the example

    SQL Fiddle DEMO

    Somethign like

    UPDATE MyTable
    SET CurrentCredit = 
    CASE 
      WHEN CurrentCredit BETWEEN 1 AND 15
        THEN CurrentCredit + 1
      WHEN CurrentCredit BETWEEN 16 AND 30
        THEN CurrentCredit +2
      WHEN CurrentCredit >= 31
        THEN CurrentCredit * 10
      ELSE CurrentCredit
    END
    

    Also, remeber that if CurrentCredit is a FLOAT, and not an INT you might want to try something like

    UPDATE MyTable
    SET CurrentCredit = 
    CASE 
      WHEN CurrentCredit >= 1 AND CurrentCredit < 16
        THEN CurrentCredit + 1
      WHEN CurrentCredit >= 16 AND CurrentCredit < 31
        THEN CurrentCredit +2
      WHEN CurrentCredit >= 31
        THEN CurrentCredit * 10
      ELSE CurrentCredit
    END;
    

    EDIT

    For the corrected request (>= 31 CurrentCredit + CEILING(CurrentCredit * 0.1)) have a look at using CEILING

    UPDATE MyTable
    SET CurrentCredit = 
    CASE 
      WHEN CurrentCredit BETWEEN 1 AND 15
        THEN CurrentCredit + 1
      WHEN CurrentCredit BETWEEN 16 AND 30
        THEN CurrentCredit +2
      WHEN CurrentCredit >= 31
        THEN CurrentCredit + CEILING(CurrentCredit * 0.1)
      ELSE CurrentCredit
    END;
    

    SQL Fiddle DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need my QT application to create a table and copy this table into
I need to have MySQL query like this one: UPDATE table_name SET 1 =
So I have this SQL table that I need to update. Now we use
I'm very new at this, but I need to create new tables from existing
This is my table for a mysql database. http://the44.simorasic.com/cages.html I need to show the
This question is not about caching. I need this in-memory table for many small
i need to do this : There is a table called table1 it has
i need to do this : There is a table called table1 it has
I need to change table name from lowercase to uppercase but using this statement
this is the situation: I need horizontal scrolling, and table views inside every page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.