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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:57+00:00 2026-05-31T18:06:57+00:00

How do I check status in where clause? SELECT `id`,`name`,`start_date`,`end_date`, CASE WHEN SYSDATE() <

  • 0

How do I check status in where clause?

SELECT `id`,`name`,`start_date`,`end_date`,
CASE
WHEN SYSDATE() <  `start_date` THEN 'WAITING'        
WHEN SYSDATE() >= `start_date` AND SYSDATE() <= `end_date` THEN 'START'
WHEN SYSDATE() >= `end_date`   THEN 'END'
END `status`
FROM teams WHERE `status` = 'START';

When I execute this Query they generate an error like this

enter image description here

See database screenshot also

enter image description here

  • 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-31T18:06:59+00:00Added an answer on May 31, 2026 at 6:06 pm

    The problem is that you can’t reference your computed column by name in the same query. So you need to use an inner sub-query:

    SELECT `id`,`name`,`start_date`,`end_date`, `status`
    FROM (
      SELECT `id`,`name`,`start_date`,`end_date`,
        CASE
          WHEN SYSDATE() <  `start_date` THEN 'WAITING'        
          WHEN SYSDATE() >= `start_date` AND SYSDATE() <= `end_date` THEN 'START'
          WHEN SYSDATE() >= `end_date`   THEN 'END'
        END `status`
      FROM teams) AS T
    WHERE `status` = 'START';
    

    Or you can duplicate the logic in your WHERE clause, but most people prefer not to do that. Also note that this solution allows you to simply change your WHERE clause to get the other result sets:

    • WHERE status = 'WAITING'
    • WHERE status = 'END'

    You don’t have to mess around with the logic after it’s set up this way.

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

Sidebar

Related Questions

I have used checkbox column in gridview. I want to check status of that
How can I check the status of an IIS6 application pool with C# ?
t-sql, sql server 2008 My application must check connection status to database every 5
I want to check the login status of a user through an ajax request.
How can NSNotification be used to check a the status of an NSTask? I
I want to download a file and need to check the response status code
I'm creating a small tool which let me to check status of ports of
There are 4 fields: Name,Status,Activities Performed And Region.We have to make search tool so
Possible Duplicate: Check status of services that run in a remote computer using C#
I try this query from Oracle : select * from a_table@Postgres; Here is the

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.