|
satya068
Posting Yak Master
USA
230 Posts |
Posted - 11/12/2012 : 10:37:08
|
Hello,
This is my SP created for getting the percentage of the ward for the month of april, I need this to repeat every month from April2012 and should load into the table.How to set the dates in SP to get the percentage for every month?
ALTER PROCEDURE [dbo].[sp_EstimatedDischargeDate] AS BEGIN SET NOCOUNT ON;
SELECT XX.EDD/(select CAST(count(*) as Int) as "TEP" from (select * from ( select DISTINCT admission_number, admission_date, discharge_date ,estimated_discharge_date, create_date, DIM_BA_ADM.update_date,CURRENT_WARD_CODE,current_flag, ROW_NUMBER() OVER(PARTITION BY admission_number ORDER BY admission_date) AS TEP from DIM_BA_ADM WHERE DATEDIFF(YEAR,person_date_of_birth,ADMISSION_DATE) >=65 and CURRENT_WARD_CODE in ('8548*EEP') and admission_date between '2012-06-01 00:00:00.000' and '2012-06-30 00:00:00.000')S WHERE TEP=1) as y )
FROM (select CAST(count(*) as Int)*100 as "EDD" from (select DISTINCT A.ADMISSION_NUMBER from DIM_BA_ADM A INNER JOIN (select * from DIM_BA_ADM B where B.current_flag ='Y') B ON A.ADMISSION_NUMBER =B.ADMISSION_NUMBER WHERE A.CURRENT_WARD_CODE in ('8548*EEP') and A.admission_date between '2012-06-01 00:00:00.000' and '2012-06-30 00:00:00.000') as X) as XX END
Thanks |
Edited by - satya068 on 11/12/2012 10:51:29
|
|