I have a simple table in SQL server 2008.
SELECT TOP lastupdated, remarks FROM table
I want to select the following criteria.
if remarks is 'Others' and DATEDIFF(MINUTE, LastUpdated, GETDATE() ) > 15
then select these rows
Additionally, I want to select following in the same query
if remarks is not 'Others'
then select these rows without waiting for 15 minutes
You can do the following:
select LastUpdated, Remarks
from table
where (remarks = 'Others' and datediff(min, LastUpdated, GETDATE()) > 15)
or remarks != 'Others'
You can adjust the TOP x, according to your needs, since you didn't put it in your question so I didn't know how many rows you needed to select.
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