Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
USE [ddws_imis2008]
GO
/****** Object:  StoredProcedure [ddws_imis].[PMS_GetMyMprStatusMonth]    Script Date: 12/11/2013 09:44:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

--PMS_GetMyMprStatusMonth '2013-2014'
ALTER Procedure [ddws_imis].[PMS_GetMyMprStatusMonth] 
@FinYear varchar(40)
as
begin
select 
StateName,
DistrictName,
BlockName,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=1 and FinYear=@FinYear and AchievedStatus>=1),'')Jan,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=2 and FinYear=@FinYear and AchievedStatus>=1),'')Feb,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=3 and FinYear=@FinYear and AchievedStatus>=1),'')Mar,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=4 and FinYear=@FinYear and AchievedStatus>=1),'')Apr,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=5 and FinYear=@FinYear and AchievedStatus>=1),'')May,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=6 and FinYear=@FinYear and AchievedStatus>=1),'')Jun,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=7 and FinYear=@FinYear and AchievedStatus>=1),'')Jul,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=8 and FinYear=@FinYear and AchievedStatus>=1),'')Aug,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=9 and FinYear=@FinYear and AchievedStatus>=1),'')Sep,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=10 and FinYear=@FinYear and AchievedStatus>=1),'')Oct,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=11 and FinYear=@FinYear and AchievedStatus>=1),'')Nov,
ISNULL((select COUNT(*) from WSP_ActivityMPR where BlockId=WAM.BlockId And Monthid=12 and FinYear=@FinYear and AchievedStatus>=1),'')Dec
into #t
from PMS_StateDistrict WAM

select StateName, DistrictName,BlockName,
 Jan, 
 Feb,
 Mar,
 Apr,
 May,
 Jun,
 Jul,
 Aug,
 Sep,
 Oct,
 Nov,
 Dec 
 From #t 

drop table #t

end
Posted
Comments
creepz03 11-Dec-13 2:43am    
I'm having a hard time comprehending your question.. could you re-phrase? :( Or be more specific.
OriginalGriff 11-Dec-13 2:53am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So explain in better detail, but please: shorten the subject to ten or so words - don;t try to put your whole question in there as it will get truncated!
Use the "Improve question" widget to edit your question and provide better information.

1 solution

I am guessing that you want to show "No" if the value is 0 and "Yes" otherwise for months field. If the assumption is correct then check the query for the same. I have done it for only one field do to same for other fields as well.

SQL
select StateName, DistrictName,BlockName,
 case when Jan > 0 Then 'Yes' else 'No' end JAN,
 Feb,
 Mar,
 Apr,
 May,
 Jun,
 Jul,
 Aug,
 Sep,
 Oct,
 Nov,
 Dec
 From #t
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900