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

  • SEARCH
  • Home
  • 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 8367807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:01+00:00 2026-06-09T13:15:01+00:00

I have a table with 3 text columns on which I want to do

  • 0

I have a table with 3 text columns on which I want to do some mathematical calculations.
Table looks like below:

Date        Column1    Column2    Column3
-----------------------------------------
2012-08-01  STABLE     NEG        STABLE
2012-08-02  NEG        NEG        STABLE
2012-08-03  STABLE     STABLE     STABLE

Want I want to achieve is

  • If 2/3 columns is equal to ‘STABLE’ then it returns 66% i.e. 2/3, as it is in the first row
  • If 1/3 columns is equal to ‘STABLE’ then it returns 33% i.e. 1/3, as it is in the second row
  • If 3/3 columns is equal to ‘STABLE’ then it returns 100% i.e. 3/3, as it is in the third row

I want to know how I can achieve this using SQL? I’m currently working on MSSQL Server 2008 R2.

I hope my question is clear enough.

  • 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-09T13:15:02+00:00Added an answer on June 9, 2026 at 1:15 pm

    So, something like this?

    select 
       ((case when col1 = 'Stable' then 1.0 else 0.0 end) + 
       (case when col2 = 'Stable' then 1.0 else 0.0 end) + 
       (case when col3 = 'Stable' then 1.0 else 0.0 end)) / 3.0
    from yourtable
    

    You can do some formatting on the output, but should be very close to what your looking for.

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

Sidebar

Related Questions

I have a table with 3 columns ---QID---TEXT---CID--- I would like to find 20
I have created a table and there is some text in which column of
I have a MySQL InnoDB table with 238 columns. 56 of them are TEXT
I have a table which has two text boxes and an image beside it
I have a table with a lot of text inputs like these: alt text
BACKGROUND: I would like to have small labels in columns of a table. I'm
I have a PostgreSQL\PostGIS spatial database which contains Hebrew text columns. The system runs
I have a table with some columns with data as large as 8000 characters.
i have database table with few text fields which i use to filter data
I have a table in SQL Server in which one of the columns is

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.