Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I'm trying to use the following statement to check if the order is late, but it causes syntax error. How can I write it ?
select (enddate > targetdate ) as late from orders
SELECT enddate, targetdate FROM orders WHERE enddate > targetdate
It looks like you're searching something similar to case expression:
case
select case when enddate > targetdate then 1 else 0 end as late from orders
Add a comment
I guess you need case
select case when enddate > targetdate then 'enddate is greater' else 'targetdate is greater' end as late from orders
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
SELECT enddate, targetdate FROM orders WHERE enddate > targetdate?