I'm only listing snippets of the query which are sub queries.
Below sub query displays the month if a certain task (TaskID 1) is closed on the same month or displays "0" if it is not closed in the same month. Plus it displays the activity note in detail for that ONE task(Task ID 1). this is all working fine for me
(SELECT Top 1 case when Month(TaskFinish)=Month(TaskSTart) THEN Month(TaskStart) ELSE '0' END FROM Tasks T WHERE ticketid = 140 And TaskID=1 AND ttype =1 ORDER BY TaskSTart desc) [TaskStartClosedMonth], (SELECT Top 1 Response FROM Tasks T INNER JOIN Response2 R ON R.QAssignID=AssignID WHERE T.ticketid = 140 And T.TaskID=1 AND ttype =1 ) [ResponseDetail],
The above queries is for only ONE Task. I need to incorporate 3 tasks
I need to display the month for ANY of the THREE tasks (TaskID1,TaskID2,TaskID3) that were started and closed in same month, if no match found then display 0.
If it finds a match say for TaskID 2 , then give me the response for TaskID 2.
In TSQL it would have been listtle easy to do that but I need to get this done in SQL query. I believe we will have Case satements and conditions?