I want to write a sql query for the following excel-query. What should be the appropriate query?
IF
(
(project. PA_SUBMIT_DATE )-(project. PA_AGREED_SUBMIT_DATE)
>=0;
"YES";
"NO"
)
i.e Date difference should be greater than or equal to zero. If so return yes else no.Please help me here.
It would look something like this:
(case when project.PA_SUBMIT_DATE >= project.PA_AGREED_SUBMIT_DATE
then 'YES' else 'NO'
end)
Note: You can use >=
for dates in both Excel and SQL and (I think) it makes the code easier to understand. The rest is just the standard SQL for a condition in a select
.
Looks like you want to return a "YES" if the PA_SUBMIT_DATE
is greater than or equal to the PA_AGREED_SUBMIT_DATE
:
SELECT CASE WHEN PA_SUBMIT_DATE >= PA_AGREED_SUBMIT_DATE
THEN 'YES' ELSE 'NO'
END AS [ColumnName]
FROM PROJECT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With