亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 附件代理領銷存情況查詢.sql

?? 手機進銷存系統Delphi源碼,管理手機的進貨還有銷售方面的功能
?? SQL
字號:
/***********************************************
統計代理附件每種類型的進貨
@fall 標記是否查找萬能ALL,所有的機型(萬能機型和適用機型)BFJ只查詢有適用機型,WLJ只查詢適用萬能機型的
@fpjzl all,所有的配件資料當對配件資料進行選擇后,就不為ALL
@act
	1:查看總表
	2:查看明細表
**************************************************/
--select f.fid,r.fmon,r.fnum,r.fdate, from tfjrc r
declare @ffdate datetime
declare @fedate datetime

declare @fpjzl char(5)--配件資料all,所有的配件資料
declare @fadr char(4)--配件貨源地
declare @fname char(5)--配件廠商
declare @fpjlx char(2)--配件類型--附件類型 ALL為所有附件類型
declare @fjx char(5)--標記查找的機型'ALL為所有'
declare @fall char(3)--標記是否查找萬能ALL,所有的機型(萬能機型和適用機型)BFJ只查詢有適用機型,WLJ只查詢適用萬能機型的
declare @act int
declare @lx char(2)
DECLARE @GT CHAR(4)

declare @temp table
(
flx char(2),
fid char(12),
fpjzl char(5),
fmon  money,
fnum int,
fdate datetime,
fgt char(4)



)
declare @temppjzl table
(
fid char(12)
)

declare @tempcount table
(
fgt char(4),
flx char(2),
fpjzl char(5),
ffjlx char(10),
ffjcs char(15),
fjx char(20),
fnum int
)

declare @tempwx table
(
fgt char(4),
flx char(2),
fpjzl char(5),
ffjlx char(10),
ffjcs char(16),
fjx char(20),
fnum int,
fxc int,
fth int,
fwxnum int
)
set @ffdate='2001-01-01'
set @fedate='2005-12-30'


set @fpjzl='000'
set @fadr='ALL'
set @fname='ALL'
set @fpjlx='AL'
set @fjx='ALL'
set @fall='ALL'
set @act=3
set @lx='AL'


SET @GT='ALL'

IF @GT='ALL'
	SET @GT='%%'



if @lx='AL'
set @lx='%%'



if @fadr='ALL'
 set @fadr='%%'
if @fname='ALL'
 set @fname='%%'
if @fpjlx='AL'
set @fpjlx='%%'
if @fjx='ALL'
set @fjx='%%'

--得到配件資料
	if @fpjzl='ALL' 
	begin

		insert @temp
		select (
			case substring(fid,1,2)
				when 'FL' then 'FL'
				when 'FX' then 'FS'
				when 'FT' then 'FT'
			end
					
				) as flx,fid,fpjzl,fmon,fnum,fdate,fgt
		from tglfj
		where  fdate>=@ffdate and fdate<=@fedate and fgt like ltrim(rtrim(@gt))

	end


	if @fpjzl<>'ALL'
		begin
				if @fall='ALL'--當不是查找所有的附件類型 資料時,但是附件的適用機型又是所有的情況
				begin
					insert  into @temppjzl
					select fid 
					from tpjzl
					where fname like ltrim(rtrim(@fname ))
						and fpjlx like ltrim(rtrim(@fpjlx))
						
				end
				if @fall='BFJ'--只查部分適用機型
					insert  into @temppjzl
					select fid 
					from tpjzl
					where fname like ltrim(rtrim(@fname ))
						and fpjlx like ltrim(rtrim(@fpjlx))
						and fjx like ltrim(rtrim(@fjx))
				if @fall='WLJ'--只查部分適用機型
					insert  into @temppjzl
					select fid 
					from tpjzl
					where fname like ltrim(rtrim(@fname ))
						and fpjlx like ltrim(rtrim(@fpjlx))
						and fjx is null
		insert @temp
		select (
			case substring(fid,1,2)
				when 'FL' then 'FL'
				when 'FX' then 'FS'
				when 'FT' then 'FT'
			end
					
				) as flx,fid,fpjzl,fmon,fnum,fdate,fgt
		from tglfj
		where  fdate>=@ffdate and fdate<=@fedate and fgt like ltrim(rtrim(@gt)) and fpjzl in (select fid from @temppjzl)
	end	



			insert into @tempcount
			select a.fgt,a.flx,a.fpjzl,b.ffjlx,b.ffjcs,b.fjx,a.fnum
			from(	
				--統計出總數
				
						select top 10000 fgt,flx,fpjzl,sum(fnum) as fnum
						from @temp
						group by fgt,flx,fpjzl
						order by fgt,flx,fpjzl
					
				
			     )a,(	
				--查看附件類型 
				select top 10000 p.fid,ltrim(rtrim(tfjcs.fna))as ffjcs,ltrim(rtrim(f.fname)) as ffjlx,
					ltrim(rtrim((case 
							when p.fjx is null then '萬能'
							when p.fjx is not null then (select ltrim(rtrim(tsjcs.fna))+ltrim(rtrim(tsjxh.fmodel)) from tsjxh,tsjcs where tsjcs.fid=tsjxh.fsjcs and  tsjxh.fid=p.fjx)
						      end))) as fjx

				 from tpjzl p,tfjlx f,tfjcs
				 where f.fid=p.fpjlx and tfjcs.fid=p.fname
			     )b
			where a.fpjzl=b.fid --and a.flx like @lx
			order by a.fgt,a.flx,b.ffjlx,b.ffjcs,b.fjx
	--得到未銷的數據	




	insert into @tempwx
	select  a.fgt,'FW' as flx,a.fpjzl,a.ffjlx,a.ffjcs,a.fjx,a.fnum,isnull(b.fxcnum,0)as fxcnum,isnull(b.fthnum,0) as fthnum,isnull(b.fwxnum,a.fnum) as fwxnum
	from(
			select top 10000 * 
			from 	@tempcount a
			where a.flx='FL'
		)a left outer join
		(
				select  top 10000 a.fgt,a.fpjzl,a.ffjlx,a.ffjcs,a.fjx,b.fnum as fxcnum,(a.fnum-b.fnum-c.fnum) as fwxnum,c.fnum as fthnum
				from
				(
					select top 10000 * 
					from @tempcount a
					where a.flx='FL'
				)a,  
				(
					select top  10000 * 
					from @tempcount a
					where a.flx='FS'
					)b,
					(
					select top  10000 * 
					from @tempcount a
					where a.flx='FT'
				)c
	 where a.fpjzl=b.fpjzl and a.fgt=b.fgt and  a.fpjzl=c.fpjzl and c.fgt=a.fgt and b.fpjzl=c.fpjzl and b.fgt=c.fgt
	
	)b
	on a.fpjzl=b.fpjzl and a.fgt=b.fgt
	order by a.fgt,a.fpjzl,a.ffjcs,a.fjx
--select * from @tempcount	
--select * from @temp
--select * from @tempwx

if @act=1
begin
		--統計出每種型號的數據量
	select ltrim(rtrim(tgt.fna)) as fgt,a.flx,
			(case a.flx
			 when 'FL' then '領貨'
			 when 'FS' then '銷售'
			 when 'FT' then '退貨'
       		         when 'FW' then '庫存'
			 end
			) as flxcn,	
				a.ffjlx,a.fjx,a.fallcount
	from
	(
		select  top 10000 a.*
		from
			(	
			select  top 10000 b.fgt,b.flx,ltrim(rtrim(b.ffjlx)) as ffjlx,ltrim(rtrim(b.fjx)) as fjx,sum(b.fnum) as fallcount
			from @tempcount b
			group by b.fgt,b.flx,b.ffjlx,b.fjx
			order by b.fgt,b.flx,ltrim(rtrim(b.ffjlx)),ltrim(rtrim(b.fjx))
			)a 
		union
		select  top 10000 a.*
		from
			(
			select top 10000 a.fgt,a.flx,ltrim(rtrim(a.ffjlx)) as ffjlx,ltrim(rtrim(a.fjx)) as fjx,sum(fwxnum) as fallcount
			from @tempwx a
			group  by a.fgt,a.flx,a.ffjlx,a.fjx
			order by  a.fgt,a.flx,ltrim(rtrim(a.ffjlx)),ltrim(rtrim(a.fjx))
			)a
	)a,tgt
	where a.flx like @lx and tgt.fid=a.fgt
	order by a.fgt,a.flx
end






if @act=2 
begin	
		select ltrim(rtrim(tgt.fna)) as fgt,a.flx,
				(case a.flx
					 when 'FL' then '領貨'
					 when 'FS' then '銷售'
					 when 'FT' then '退貨'
		       		         when 'FW' then '庫存'
					 end
				) as flxcn,
						a.ffjlx,a.fjx,a.fallcount,a.ffjcs,a.fnum
		from(
			select  top 10000 a.* 
			from (	

				SELECT  top 10000 a.fgt,a.flx,ltrim(rtrim(a.ffjlx)) as ffjlx,ltrim(rtrim(a.fjx)) as fjx,a.fallcount,ltrim(rtrim(b.ffjcs)) as ffjcs,b.fwxnum	as fnum
				from
					(	
	
					select top 10000 a.fgt,a.flx,ltrim(rtrim(a.ffjlx)) as ffjlx,ltrim(rtrim(a.fjx)) as fjx,sum(fwxnum) as fallcount
					from @tempwx a
					group  by a.fgt,a.flx,a.ffjlx,a.fjx
					--order by  a.flx,ltrim(rtrim(a.ffjlx)),ltrim(rtrim(a.fjx))
					)A,@TEMPWX B
				WHERE a.ffjlx=b.ffjlx and a.fjx=b.fjx and a.fgt=b.fgt
				--order by a.flx,b.ffjlx,b.fjx,b.ffjcs
			    )a
			union
			select  top 10000 a.* 
			from (
				--統計出總數據報表
				select  top 10000  a.fgt,a.flx,ltrim(rtrim(a.ffjlx))as ffjlx,ltrim(rtrim(a.fjx)) as fjx,a.fallcount,ltrim(rtrim(b.ffjcs)) as ffjcs,b.fnum
				from
					(
					select top 1000 b.fgt,b.flx,b.ffjlx,b.fjx,sum(b.fnum) as fallcount
					from @tempcount b
					group by b.fgt,b.flx,b.ffjlx,b.fjx
					--order by b.flx,ltrim(rtrim(b.ffjlx)),ltrim(rtrim(b.fjx))
					)a,
					(
					select top 10000 a.fgt,a.flx,a.fpjzl,b.ffjlx,b.ffjcs,b.fjx,a.fnum
					from(	
						--統計出總數
				
								select top 10000 fgt,flx,fpjzl,sum(fnum) as fnum
								from @temp
								group by fgt,flx,fpjzl
								--order by flx,fpjzl
					
				
					     )a,(	
						--查看附件類型 
						select top 10000 p.fid,ltrim(rtrim(tfjcs.fna))as ffjcs,ltrim(rtrim(f.fname)) as ffjlx,
							ltrim(rtrim((case 
									when p.fjx is null then '萬能'
									when p.fjx is not null then (select ltrim(rtrim(tsjcs.fna))+ltrim(rtrim(tsjxh.fmodel)) from tsjxh,tsjcs where tsjcs.fid=tsjxh.fsjcs and  tsjxh.fid=p.fjx)
								      end))) as fjx

						 from tpjzl p,tfjlx f,tfjcs
						 where f.fid=p.fpjlx and tfjcs.fid=p.fname
					     )b
					where a.fpjzl=b.fid 
					--order by a.flx,b.ffjlx,b.ffjcs,b.fjx
					)b
				where a.fgt=b.fgt and a.flx=b.flx and ltrim(rtrim(a.ffjlx))=ltrim(rtrim(b.ffjlx)) and ltrim(rtrim(a.fjx))=ltrim(rtrim(b.fjx))
				--order by a.flx,a.ffjlx,a.fjx,b.ffjcs
			    )a
		)a,tgt
		where a.flx like @lx and tgt.fid=a.fgt
		order by a.fgt,a.flx,a.ffjlx,a.fjx,a.ffjcs
	
end	







if @act=3 
begin

	select ltrim(rtrim(tgt.fna)) as fgt,a.flx,
			(case a.flx			
				 when 'FL' then '領貨'
				 when 'FS' then '銷售'
				 when 'FT' then '退貨'
     			         when 'FW' then '庫存'
			end
		) as flxcn,
					a.ffjlx,a.fjx,a.fallcount,a.ffjcs,a.fnum,a.fdate,a.fnumb
	from
		(
			SELECT TOP 10000 a.* ,null as fdate,null as fnumb
			FROM
			    (	
				SELECT  top 10000 a.fgt,a.flx,ltrim(rtrim(a.ffjlx)) as ffjlx,ltrim(rtrim(a.fjx)) as fjx,a.fallcount,ltrim(rtrim(b.ffjcs)) as ffjcs,b.fwxnum	as fnum
				from
					(	
	
					select top 10000 a.fgt,a.flx,ltrim(rtrim(a.ffjlx)) as ffjlx,ltrim(rtrim(a.fjx)) as fjx,sum(fwxnum) as fallcount
					from @tempwx a
					group  by a.fgt,a.flx,a.ffjlx,a.fjx
					--order by  a.fgt,a.flx,ltrim(rtrim(a.ffjlx)),ltrim(rtrim(a.fjx))
					)A,@TEMPWX B
				WHERE a.ffjlx=b.ffjlx and a.fjx=b.fjx and a.fgt=b.fgt
				--order by a.flx,b.ffjlx,b.fjx,b.ffjcs
			  )a
			union
  			SELECT TOP 10000 *
			FROM
			(
			select 	a.fgt,a.flx,a.ffjlx,a.fjx,a.fallcount,a.ffjcs,a.fnum,b.fdate,b.fnumb
			from 
				(
		
				select  top 10000 a.fgt,a.flx,ltrim(rtrim(a.ffjlx))as ffjlx,ltrim(rtrim(a.fjx)) as fjx,a.fallcount,ltrim(rtrim(b.ffjcs)) as ffjcs,b.fnum
				from
					(
					select top 1000 b.fgt,b.flx,b.ffjlx,b.fjx,sum(b.fnum) as fallcount
					from @tempcount b
					group by b.fgt,b.flx,b.ffjlx,b.fjx
					--order by b.flx,ltrim(rtrim(b.ffjlx)),ltrim(rtrim(b.fjx))
					)a,
					(
					select top 10000 a.fgt,a.flx,a.fpjzl,b.ffjlx,b.ffjcs,b.fjx,a.fnum
					from(	
						--統計出總數
				
								select top 10000 fgt, flx,fpjzl,sum(fnum) as fnum
								from @temp
								group by fgt,flx,fpjzl
								--order by flx,fpjzl
					
				
					     )a,(	
						--查看附件類型 
						select top 10000 p.fid,ltrim(rtrim(tfjcs.fna))as ffjcs,ltrim(rtrim(f.fname)) as ffjlx,
							ltrim(rtrim((case 
									when p.fjx is null then '萬能'
									when p.fjx is not null then (select ltrim(rtrim(tsjcs.fna))+ltrim(rtrim(tsjxh.fmodel)) from tsjxh,tsjcs where tsjcs.fid=tsjxh.fsjcs and  tsjxh.fid=p.fjx)
								      end))) as fjx

						 from tpjzl p,tfjlx f,tfjcs
						 where f.fid=p.fpjlx and tfjcs.fid=p.fname
					     )b
					where a.fpjzl=b.fid 
					--order by a.flx,b.ffjlx,b.ffjcs,b.fjx
					)b
				where a.fgt=b.fgt and a.flx=b.flx and ltrim(rtrim(a.ffjlx))=ltrim(rtrim(b.ffjlx)) and ltrim(rtrim(a.fjx))=ltrim(rtrim(b.fjx))
				order by a.flx,a.ffjlx,a.fjx,b.ffjcs
				)a,
				(
				select  top 10000 a.*,b.fdate,b.fnum as fnumb
				from
					(
					select a.fgt,a.flx,a.fpjzl,b.ffjlx,b.ffjcs,b.fjx,a.fnum
					from(	
						--統計出總數
				
								select top 10000 fgt,flx,fpjzl,sum(fnum) as fnum
								from @temp
								group by fgt,flx,fpjzl
								--order by flx,fpjzl
					
				
					     )a,(	
						--查看附件類型 
						select top 10000 p.fid,ltrim(rtrim(tfjcs.fna))as ffjcs,ltrim(rtrim(f.fname)) as ffjlx,
							ltrim(rtrim((case 
									when p.fjx is null then '萬能'
									when p.fjx is not null then (select ltrim(rtrim(tsjcs.fna))+ltrim(rtrim(tsjxh.fmodel)) from tsjxh,tsjcs where tsjcs.fid=tsjxh.fsjcs and  tsjxh.fid=p.fjx)
								      end))) as fjx

						 from tpjzl p,tfjlx f,tfjcs
						 where f.fid=p.fpjlx and tfjcs.fid=p.fname
					     )b
					where a.fpjzl=b.fid
					)a,@temp b
				where a.fgt=b.fgt and a.flx=b.flx and a.fpjzl=b.fpjzl 
				order by a.flx,a.ffjlx,a.ffjcs,a.fjx
				)b
			where a.fgt=b.fgt and a.flx=b.flx and a.ffjlx=b.ffjlx and a.ffjcs=b.ffjcs and a.fjx=b.fjx
			--order by a.flx,a.ffjlx,a.fjx,a.ffjcs,b.fdate,b.fhyd
			)A
		)a,tgt
	where a.flx like @lx and tgt.fid=a.fgt
	order by a.fgt,a.flx,a.ffjlx,a.fjx,a.ffjcs,a.fdate
end
--select * from @temp

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品欧美一区二区三区综合在 | 婷婷开心激情综合| 精品在线一区二区| 99久久精品久久久久久清纯| 91麻豆精品国产91久久久久久久久| 久久人人超碰精品| 性欧美疯狂xxxxbbbb| 高清不卡在线观看av| 欧美最新大片在线看| 久久久久久亚洲综合影院红桃| 亚洲一区二区在线观看视频| 国产成人精品亚洲777人妖 | 国产精品 日产精品 欧美精品| 色欧美片视频在线观看在线视频| 欧美成人精品高清在线播放| 一区二区三区免费| 99精品欧美一区二区三区综合在线| 欧美美女一区二区三区| 17c精品麻豆一区二区免费| 国产一区二区在线观看视频| 欧美日韩国产首页在线观看| 中文字幕一区二| 国产一区二区在线看| 欧美精品日韩一本| 洋洋成人永久网站入口| heyzo一本久久综合| 久久婷婷国产综合精品青草 | 在线观看日产精品| 国产精品免费人成网站| 国内精品国产三级国产a久久| 4hu四虎永久在线影院成人| 亚洲综合一二区| 在线日韩国产精品| 亚洲欧美国产77777| 97精品国产露脸对白| 国产精品家庭影院| 不卡一区二区三区四区| 欧美国产激情二区三区| 国产白丝精品91爽爽久久| 2欧美一区二区三区在线观看视频| 爽爽淫人综合网网站| 欧美精品久久一区| 奇米精品一区二区三区在线观看 | 欧美乱妇15p| 亚洲成a人在线观看| 欧美日韩国产乱码电影| 日韩中文字幕亚洲一区二区va在线 | 国产视频亚洲色图| 春色校园综合激情亚洲| 中文字幕一区二区三区色视频| 成人精品国产免费网站| 国产精品第五页| 欧洲一区二区三区在线| 午夜视频在线观看一区二区| 欧美久久久久久久久久| 美女视频黄免费的久久| 久久久久久久久久久久电影| 粉嫩在线一区二区三区视频| 自拍偷拍亚洲激情| 欧美裸体bbwbbwbbw| 九色porny丨国产精品| 国产偷国产偷精品高清尤物| 99这里都是精品| 亚洲18色成人| 久久久久久久久久久电影| 成人a级免费电影| 亚洲一区二区成人在线观看| 精品久久一二三区| 成人激情文学综合网| 亚洲影院理伦片| 精品久久人人做人人爱| 97久久精品人人澡人人爽| 午夜精品久久久| 国产亚洲精品久| 在线亚洲欧美专区二区| 久久精品国产999大香线蕉| 中文字幕成人av| 欧美日韩精品系列| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 亚洲成人av一区| 国产亚洲综合性久久久影院| 在线观看日韩电影| 国产suv精品一区二区三区| 五月天亚洲精品| 中文字幕高清一区| 91精品福利在线一区二区三区| 高清成人免费视频| 日韩国产高清在线| 亚洲图片激情小说| xfplay精品久久| 欧美日韩的一区二区| 成人黄色免费短视频| 美腿丝袜亚洲综合| 亚洲黄色免费电影| 欧美激情艳妇裸体舞| 日韩欧美www| 欧美丝袜自拍制服另类| av亚洲精华国产精华精华| 久久精品国产精品亚洲综合| 亚洲男人天堂一区| 国产精品理论片| 日韩美女视频一区二区在线观看| 色综合天天性综合| 色噜噜狠狠成人中文综合| 国产精品影音先锋| 看国产成人h片视频| 日韩精品亚洲专区| 夜夜嗨av一区二区三区四季av| 中文字幕在线免费不卡| 日韩美一区二区三区| 8x福利精品第一导航| 欧美群妇大交群的观看方式| 色婷婷综合在线| 91蝌蚪国产九色| 成人综合在线视频| 粉嫩一区二区三区性色av| 国产毛片精品视频| 狠狠狠色丁香婷婷综合激情| 美女mm1313爽爽久久久蜜臀| 免费在线观看一区二区三区| 日韩经典一区二区| 日日摸夜夜添夜夜添精品视频| 亚洲线精品一区二区三区八戒| 亚洲精品中文在线| 亚洲综合在线视频| 亚洲高清一区二区三区| 亚洲福利一区二区三区| 亚洲mv大片欧洲mv大片精品| 午夜欧美大尺度福利影院在线看| 亚洲国产中文字幕| 日韩精彩视频在线观看| 麻豆成人免费电影| 国产主播一区二区| 成人黄色在线视频| 91天堂素人约啪| 欧美无砖专区一中文字| 欧美男男青年gay1069videost| 欧美一区午夜精品| 精品国产乱码久久久久久久| 欧美激情艳妇裸体舞| 综合久久一区二区三区| 亚洲国产一区二区三区| 日本大胆欧美人术艺术动态| 国产一区视频在线看| 99r国产精品| 欧美日韩一区精品| 精品国产制服丝袜高跟| 久久精品国产成人一区二区三区 | 亚洲欧洲日韩在线| 亚洲激情五月婷婷| 蜜桃视频第一区免费观看| 国内精品久久久久影院一蜜桃| www.av精品| 欧美人与性动xxxx| 久久精品视频一区| 一卡二卡欧美日韩| 毛片不卡一区二区| 99久久久久免费精品国产| 欧美日韩你懂的| 国产亚洲欧美激情| 亚洲高清在线精品| 国产一区二区免费视频| 色久综合一二码| 精品免费日韩av| 日韩理论电影院| 国内成人免费视频| 91精彩视频在线| 久久亚洲精品小早川怜子| 亚洲视频小说图片| 狠狠狠色丁香婷婷综合激情| 在线观看三级视频欧美| 国产丝袜在线精品| 婷婷综合在线观看| 91网站最新地址| 久久这里只有精品视频网| 午夜欧美在线一二页| 9l国产精品久久久久麻豆| 欧美不卡一区二区| 亚洲狠狠爱一区二区三区| 高清不卡一区二区| 精品欧美乱码久久久久久1区2区| 亚洲综合偷拍欧美一区色| 成人永久aaa| 久久综合久久99| 久久精品国产精品亚洲红杏| 欧美日韩国产一级片| 国产精品传媒入口麻豆| 国产精品一品二品| 欧美成人福利视频| 天天综合网 天天综合色| 91久久免费观看| 中文字幕亚洲一区二区av在线| 国产精品性做久久久久久| 日韩欧美在线网站| 亚洲成av人片一区二区三区| 色综合天天综合| 亚洲色图清纯唯美| 99精品黄色片免费大全| 国产欧美一区二区三区鸳鸯浴| 国产综合色在线视频区|