From today onwards I have added a new section in my blog “Question of the Week”. In this section, I will be going to ask SQL puzzle twice a week from all of you and after two days will gives the answer for that Question. So keep answering:-)
Question on 25/12/2013 :-
Suppose we have a table says tbl_students whose structure is given below:-
Create table tbl_students(Studentid int identity(1,1) , Studentname nvarchar(150))
Suppose it contains the following data:-
Answer for Question asked on 25/12/2013
Question on 28/12/2013:-
Question:- Suppose we have a table named tbl_charactername have only one column say “charactername”.
It contains 10 rows. First 5 rows contains “Vivek Johari” and the next 5 rows contains “Abhinav Golwalkar”
Now we need a SQL Query which can return the result in the form
Question of the Week -08/04/2014
Suppose we need to find out the name of all the months in a given year (Year will be given as an input parameter) where first day of the month falls on weekend (Saturday or Sunday).
So what should be the query/stored procedure to get the above result?
6 thoughts on “Question of the Week”
WITH CTE AS
SELECT 1 AS NUM UNION SELECT 3 UNION SELECT 4 UNION SELECT 8 UNION SELECT 10
SELECT MIN(NUM) AS M,MAX(NUM) AS N FROM CTE
SELECT M + 1,N FROM CTE1 WHERE M < N
SELECT M FROM CTE1 WHERE M NOT IN ( SELECT NUM FROM CTE )
Thanks for your response.
But your answer is not giving the correct answer as it gives 2,5,6,7,9. The correct answer is 3,5,8,9.
Again good going..
Add some new puzzles 🙂
Could you please suggest any Blogs and book for learning SSIS and SSRS.
could you provide tricks for query execution plan.
How can analysis DeadLock issue from " Deadlocks_0_13213.xel"
Comments are closed.