⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test2.sql

📁 工厂采购系统,DELPHI+SQL SERVER,三层技术
💻 SQL
字号:


		if(isnull(@vendor_id,'')<>'') and (isnull(@hpn,'')<>'') 
		begin
		insert into #tmp_gtr_Record(vendor_id,order_amount,Delivery_dt)
		select 
		a.id,
		sum(b.in_quantity*b.unit_Price) as Order_Amount,
		(convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))as delivery_dt
		from ord_mst a,#gtr_item_List b
		where a.pono = b.pono and a.id=@vendor_id and b.hpn like @hpn+'%'
		and (datepart(yy,b.created_dt) >=datepart(yy,@start_dt) 
		and datepart(mm,b.created_dt)>=datepart(mm,@start_dt))
		and (datepart(yy,b.created_dt) <=datepart(yy,@end_dt) 
		and datepart(mm,b.created_dt)<=datepart(mm,@end_dt)) 
		group by 
		a.id,(convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))
		order by (convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))
		end
		else if(isnull(@customer_id,'')<>'') or(isnull(@hpn,'')<>'')
		begin
			insert into #tmp_gtr_Record(vendor_id,order_amount,Delivery_dt,
		GR_Amount)
		select 
		a.id,
		sum(b.in_quantity*b.unit_Price) as Order_Amount,
		(convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))as delivery_dt,
		sum(b.in_quantity*b.unit_Price) as GR_Amount
		from ord_mst a,#gtr_item_List b
		where a.pono = b.pono and   b.hpn like @hpn+'%'
		and (datepart(yy,b.created_dt) >=datepart(yy,@start_dt) 
		and datepart(mm,b.created_dt)>=datepart(mm,@start_dt))
		and (datepart(yy,b.created_dt) <=datepart(yy,@end_dt) 
		and datepart(mm,b.created_dt)<=datepart(mm,@end_dt)) 
		group by 
		a.id,(convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))
		order by (convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))

		end
		else
		begin
			insert into #tmp_gtr_Record(vendor_id,order_amount,Delivery_dt,
		GR_Amount)
		select 
		a.id,
		sum(b.in_quantity*b.unit_Price) as Order_Amount,
		(convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))as delivery_dt,
		sum(b.in_quantity*b.unit_Price) as GR_Amount
		from ord_mst a,#gtr_item_List b
		where a.pono = b.pono --and a.id=@vendor_id
		and (datepart(yy,b.created_dt) >=datepart(yy,@start_dt) 
		and datepart(mm,b.created_dt)>=datepart(mm,@start_dt))
		and (datepart(yy,b.created_dt) <=datepart(yy,@end_dt) 
		and datepart(mm,b.created_dt)<=datepart(mm,@end_dt)) 
		group by 
		a.id,(convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))
		order by (convert(char(4),datepart(yy,b.created_dt))+'/'+convert(char(2),datepart(mm,b.created_dt)))
		
		end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -