performance - SQL Server query optimization date calculations -
i trying find more efficient way of re-writing query.
any suggestions? thinking of displaying fiscal month name number itself, compare , return month name.
(case --proj_end_fis_mon when (mymw.mfg_year_no = fyqm.fiscal_year_no , mymw.mfg_month_no = 12) (convert(varchar,(mymw.mfg_year_no-1))+'-'+(case when fm.fiscal_month_name 'jan%' '01' when fm.fiscal_month_name 'feb%' '02' when fm.fiscal_month_name 'mar%' '03' when fm.fiscal_month_name 'apr%' '04' when fm.fiscal_month_name 'may' '05' when fm.fiscal_month_name 'june' '06' when fm.fiscal_month_name 'july' '07' when fm.fiscal_month_name 'aug%' '08' when fm.fiscal_month_name 'sep%' '09' when fm.fiscal_month_name 'oct%' '10' when fm.fiscal_month_name 'nov%' '11' when fm.fiscal_month_name 'dec%' '12' end)) else (convert(varchar,mymw.mfg_year_no)+'-'+(case when fm.fiscal_month_name 'jan%' '01' when fm.fiscal_month_name 'feb%' '02' when fm.fiscal_month_name 'mar%' '03' when fm.fiscal_month_name 'apr%' '04' when fm.fiscal_month_name 'may' '05' when fm.fiscal_month_name 'june' '06' when fm.fiscal_month_name 'july' '07' when fm.fiscal_month_name 'aug%' '08' when fm.fiscal_month_name 'sep%' '09' when fm.fiscal_month_name 'oct%' '10' when fm.fiscal_month_name 'nov%' '11' when fm.fiscal_month_name 'dec%' '12' end)) end)
this tables like:
assuming have fiscal month number available:
convert( varchar(4), mymw.mfg_year_no - case when mymw.mfg_year_no = fyqm.fiscal_year_no , mymw.mfg_month_no = 12 1 else 0 end ) + '-' + right('0' + convert( varchar(2), fm.fiscal_month_no ), 2 )
Comments
Post a Comment