Reputation: 4179
I have two text box which I can get start & end dates from user. There are 3 condition here.
And finally, What should my query be?
Variables: start_date
and end_date
Query: SELECT * FROM kkmail WHERE MAIL_DATE ....
Upvotes: 0
Views: 106
Reputation: 10525
Oracle has LNNVL function to write these type of queries in a concise way, although a little confusing.
SELECT *
FROM kkmail
WHERE lnnvl(mail_date < @start_date)
AND lnnvl(mail_date > @end_date);
Upvotes: 1
Reputation: 204756
SELECT * FROM kkmail
WHERE (MAIL_DATE >= @start_date OR @start_date is null)
and (MAIL_DATE <= @end_date OR @end_date is null)
Upvotes: 3