Thursday, January 7, 2010

Call it ad-hoc or out of box thinking

Although is does not always work but, some times ad-hoc thinking makes the solution very simple. Consider the following scenario for which a very simplified solution is provided for. We may call it out of box thinking as well.

Question:
Is there a condition for the WHERE clause to display the details about the students born in the month numbers of 1[Jan], 3,4,5,7,8? The condition should not use both IN and OR operators.

Answer: Yes

Explanation: We can give the condition as follows:
where datename(m,dob) not like '%e%'
because these month(s) specified do not have the letter 'e', but all the other months have at least one 'e' in month name.

Note: The question of day is taken from SqlServerCentral.com. I want to compile selected QOD to share.

0 comments:

Post a Comment

Express your views about this post