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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:55:31+00:00 2026-05-14T06:55:31+00:00

Problem: A Database collumn has a Tristate (0,1,2). Each of the values are used

  • 0

Problem:
A Database collumn has a Tristate (0,1,2).
Each of the values are used serversidely.

The Clientcode (which cant be changed anymore) is only able to understand ‘0,1’.
In the Clients view ‘1’ is identic with ‘2’. So I want to change the SQL Query in the Database to return ‘1’, if the specific value is > 0.

My current Solution is combining 2 Selects (using UNION SELECT) with different WHERE-Clauses and returning ‘1’ or ‘0’ as static values. Now I’m looking for a solution to ‘translate’ the value within only ONE SELECT statement.

This is my current Solution:

 SELECT
dbo.Nachricht.NachrichtID, dbo.Nachricht.Bezeichnung, '1' AS BetrifftKontoeinrichtung, 
FROM         dbo.Nachricht INNER JOIN dbo.AdditionalData
ON dbo.Nachricht.NachrichtID = dbo.AdditionalData.NachrichtID

WHERE     (dbo.Nachricht.NachrichtID in ( 450,439 ))
AND dbo.AdditionalData.BetrifftKontoeinrichtung > 0

UNION SELECT
dbo.Nachricht.NachrichtID, dbo.Nachricht.Bezeichnung, '0' AS BetrifftKontoeinrichtung, 
FROM         dbo.Nachricht INNER JOIN dbo.AdditionalData
ON dbo.Nachricht.NachrichtID = dbo.AdditionalData.NachrichtID

WHERE     (dbo.Nachricht.NachrichtID in ( 450,439 ))
AND dbo.AdditionalData.BetrifftKontoeinrichtung = 0
  • 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-14T06:55:32+00:00Added an answer on May 14, 2026 at 6:55 am

    You can use a case statement, like this:

    SELECT
       dbo.Nachricht.NachrichtID, dbo.Nachricht.Bezeichnung, 
       CASE WHEN dbo.AdditionalData.BetrifftKontoeinrichtung = 0 
            THEN '0' ELSE '1' 
       END AS BetrifftKontoeinrichtung, 
    FROM dbo.Nachricht
    INNER JOIN dbo.AdditionalData
            ON dbo.Nachricht.NachrichtID = dbo.AdditionalData.NachrichtID    
    WHERE (dbo.Nachricht.NachrichtID in ( 450,439 ))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a non-nullable database column which has a default value set. When inserting
I ran into a problem where one version of my database has a column
Currently I have a database object, vacancies which has a column (foreign key) CareerLevels.
I have the next problem: The database in the system has denormalized tables with
This is probably the most classic database problem. I have an E-commerce software solution
Sir, I am having some problem regarding database in SQL Server. My project is
The problem: In my database I keep some account numbers in form: PL83102044760000870200961284 Now
that my problem: I have database table like that: id (AI) market_id 1 6
I've got a problem in my database - somehow changes sometimes are not being
I have the following problem in a Database using Access 2007 as front end

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.