Vous êtes sur la page 1sur 4

14/12/2011

USE [ssales] GO SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[mp_getmonabst1] @monf int, @yearf int, @mont int, @yeart int, @mdcode varchar(4), @msel int, @mprdcode varchar(3) = null, @mspfrom varchar(6) = null, @mspto varchar(6) = null AS if @mspfrom <> null and @mspto <> null begin set @mspfrom = space(6 - len(ltrim(rtrim(@mspfrom))))+ltrim(rtrim(@mspfrom )) set @mspto = space(6 - len(ltrim(rtrim(@mspto))))+ltrim(rtrim(@mspto)) end if @mprdcode = null begin if @msel = 1 or @msel = 3 begin if @yearf=@yeart if @mspfrom = null or @mspto = null begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcod e,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode) as a left outer join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otyear = @yearf)) and otdepcode = @mdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcod e,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode and spcode between @mspfrom and @mspto) as a left outer join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otyear = @yearf)) and otdepcode = @mdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else

if @mspfrom = null or @mspto = null begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode ,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode) as a left outer join (select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmonth <= @mont and otyear = @yeart)) and otdepcode = @mdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode ,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode and spcode between @mspfrom and @mspto) as a left outer join (select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmonth <= @mont and otyear = @yeart)) and otdepcode = @mdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end end if @msel = 2 begin if @yearf=@yeart if @mspfrom = null or @mspto = null begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode ,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode) as a inner join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otyear = @yearf)) and otdepcode = @mdcode and otcases > 0) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode ,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode and spcode between @mspfrom and @mspto) as a inner join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otyear = @yearf)) and otdepcode = @mdcode and otcases > 0) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else if @mspfrom = null or @mspto = null begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode ,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode) as a inner join

(select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmonth <= @mont and otyear = @yeart)) and otdepcode = @mdcode and otcases > 0) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode ,otsmcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode and spcode between @mspfrom and @mspto) as a inner join (select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmonth <= @mont and otyear = @yeart)) and otdepcode = @mdcode and otcases > 0) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end end end else begin if @yearf=@yeart if @mspfrom = null or @mspto = null begin if @msel = 2 begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode,ots mcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdc ode) as a inner join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otye ar = @yearf)) and otdepcode = @mdcode and otprdcode = @mprdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode,ot smcode,otbottle,otclosed from (select spcode from salshop where spdepcode = @md code) as a left join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otye ar = @yearf)) and otdepcode = @mdcode and otprdcode = @mprdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode,otsmco de,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode and spcode between @mspfrom and @mspto) as a inner join (select * from salofftake where ((otmonth >= @monf and otmonth <= @mont and otye

ar = @yearf)) and otdepcode = @mdcode and otprdcode = @mprdcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else if @mspfrom = null or @mspto = null begin if @msel = 2 begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode,otsmco de,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode ) as a inner join (select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmo nth <= @mont and otyear = @yeart)) and otdepcode = @mdcode and otprdcode = @mpr dcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode,otsmco de,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode ) as a left join (select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmo nth <= @mont and otyear = @yeart)) and otdepcode = @mdcode and otprdcode = @mpr dcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end end else begin select spcode,otprdcode,otcases,otmonth,otyear,otdepcode,otsmco de,otbottle,otclosed from (select spcode from salshop where spdepcode = @mdcode and spcode between @mspfrom and @mspto) as a inner join (select * from salofftake where ((otmonth >= @monf and otyear = @yearf) or (otmo nth <= @mont and otyear = @yeart)) and otdepcode = @mdcode and otprdcode = @mpr dcode) as b on a.spcode = b.otspcode order by spcode,otprdcode,otyear,otmonth end end

http://www.sabarimala.keralapolice.gov.in/en/q-coupon.html

Vous aimerez peut-être aussi