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 8526655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:20:01+00:00 2026-06-11T08:20:01+00:00

My Data is ID SCORE 1 55 1 -1 1 25 1 -1 1

  • 0

My Data is

ID       SCORE
 1        55
 1        -1
 1        25
 1        -1
 1        -1
 1        35
 2        25
 2        -1 
 2        65
 2        55
 2        21
 2        -1

Now i want to add/sum the score of each id ignoring -1 and i am trying with this code which is not working

SELECT SUM(CASE when SCORE>-1 THEN SUM(SCORE) ELSE 0 END) 
FROM jbit WHERE htno='$id'

Here i am already using WHERE so how can i use another WHERE, if i use multiple Where in single query it may effect other processes.. please help me out

Help me out friends

  • 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-11T08:20:03+00:00Added an answer on June 11, 2026 at 8:20 am

    if there is only two column then there is no need to use SUM, you can try below

    SELECT id, IF(SCORE=-1,0,SCORE) AS scoreSum
    FROM table1
    GROUP BY id
    

    Working DEMO

    alternative ( not tested )

    SELECT id, SUM(IF(SCORE=-1,0,SCORE)) AS scoreSum
    FROM table1
    WHERE htno =$id
    GROUP BY id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame in R that looks like this: score rms template aln_id
Following code iterates through many data-rows, calcs some score per row and then sorts
I have a JSON data store used for a combobox selection which is working
Let's say I have this code: class Score { public Update(int score) { update
I'm trying to add a bunch of components to my container using data populated
This is a common case for a developer. You want to add a feature
I am working with nHibernate, and trying make sense of bag collections. My data
I have table to test score data that I need to pivot and I
I have a data source, containing the following columns: ID | Tile | Score
I want to define the data.store that store companyList, because I want to reuse

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.