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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:43:23+00:00 2026-05-15T17:43:23+00:00

I´d love to do something like this, but with a working syntax of course

  • 0

I´d love to do something like this, but with a working syntax of course 🙂

MIN(CASE WHEN col=2 
THEN CASE WHEN answer IS NULL THEN 0 ELSE answer END END)

i am trying to prevent a view from getting NULL values and use zeros instead.
Here is my SELECT query that creates the view:

SELECT result,question_id,
MIN(CASE WHEN col=1
THEN answer
END) AS col1,
MIN(CASE WHEN col=2 
THEN answer
END) AS col2,
MIN(CASE WHEN col=3
THEN answer
END) AS col3
FROM answers 
GROUP by result,question_id

Basically I get a nice result that looks like this

result   question_id   col1   col2   col3
1            2          10     20      70
2            2          80     20     NULL
3            3          0     100       0

I do not have any performance problems and the original table is updated regularly that´s why I’d love to stay with the view as opposed to a sp. The table that you see disperse a relational structure of a survey that surveys probabilities. That the cols of every row have to add up to 100. If someone is really sure that something e.g. col3 wont happen he can either fill in 0 to the other form fields or leave the field blank. The form validator checks only if it all adds up to 100. If the field is left blank, the relational there is NO entry in the relational table, so the dispersed view writes a NULL.

I´d love to make it write a “0” but i do not know how! Thx for any suggestions in advance!

  • 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-05-15T17:43:24+00:00Added an answer on May 15, 2026 at 5:43 pm

    You’re looking for IFNULL(..something...,0)


    Apparently have to spell it out:

    IFNULL(MIN(CASE WHEN col=3 THEN answer END),0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think it's safe to say everyone loves doing something like this in Rails:
Edit: There is a somewhat strange solution to this question. Check my answer posted
I know there are plenty of resources on this but I'm having a tough
I'm working on a console based file browser for Windows in C++ and am
I just read amending a single file in a past commit in git but
I'm working on a project where I need to generate end-user documentation for a
Is there an awk-like or sed-like command line hack I can issue to generate
I am currently looking at building an Open Source People Intelligence Application (Fancy Word
I have been busy with the cakePHP framework for a couple of months now
I have List object filled with instances of a custom struct. list.Add(new Mail(mail1, test11,

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.