How solve conditional format for month in sql server

Posted by Cpatil1000 under Sql Server on 10/29/2014 | Points: 10 | Views : 392 | Status : [Member] | Replies : 1
Hi,
I want solve a problem following with passing parameter in sql

1) If @MONTH Between(4 & 12 ) Then Month Select between( 4 to 12)
2) If @MONTH Between(1 & 3 ) Then Month Select between( 4 to 1 or 2 or 3)

Select B.REGION_ID, B.DISTRICT_ID, SUM(B.TACKLED_TOTAL+B.COVERED_TOTAL) as 'TARGET'
Into #Temp2 From MPR_STATEMENT_A B
Where B.MONTH =(Case When @MONTH Between 4 and 12 Then (A.MONTH >= 4 and A.MONTH <= @MONTH)
When @MONTH Between 1 and 3 Then (A.MONTH > 4 and A.MONTH <= @MONTH) End)
And B.YEAR = @YEAR
Group by B.REGION_ID, B.DISTRICT_ID
End




Responses

Posted by: Bandi on: 10/30/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Can you explain expected result with sample data?

I can provide you the solution if u post sample data along with expected result

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response