sql 隐藏镜头报告 - 生成订单数量报告

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 隐藏镜头报告 - 生成订单数量报告相关的知识,希望对你有一定的参考价值。

select
	CONVERT(VARCHAR(10), orders.orderdate, 101) as 'Date',
	orders.patientid as 'Pt ID',
	orders.orderid as 'OrderID',
	(select firstname from employee where employee.employeeid = orders.employeeid) as 'Created By',
	(select firstname from employee where employee.employeeid = orders.deliveredbyemployeeid) as 'C/O By',
	order_detail.qty_od as 'OD Qty',
			--Total Lenses purchases OD
			--order_detail.qty_od * lens_qty_val as 'OD TL',
	order_detail.odlensname as 'OD Lens',
	order_detail.qty_os as 'OS Qty',
			--Total Lenses purchases OS
			--order_detail.qty_os * lens_qty_val as 'OS TL',
	order_detail.oslensname as 'OS Lens',
			--isnull((select systemdesc from domain where domainid = wearing_schedule),0)number_of_days,
			--CASE convert(varchar, (order_detail.qty_os * lens_qty_val * isnull((select systemdesc from domain where domainid = contactinventory.wearing_schedule),0)) + (order_detail.qty_od * lens_qty_val * isnull((select systemdesc from domain where domainid = contactinventory.wearing_schedule),0)))
			--CASE Convert(varchar, (order_detail.qty_os * lens_qty_val) + (order_detail.qty_od * lens_qty_val))
	CASE convert(varchar, ((order_detail.qty_os * lens_qty_val * contactinventory.wearing_schedule) + (order_detail.qty_od * lens_qty_val * contactinventory.wearing_schedule)))
				WHEN '6301440' THEN 'Year'
				WHEN '210144' THEN 'Year'
				WHEN '9452160' THEN 'Year'
				WHEN '420144' THEN 'Year'
				WHEN '3150720' THEN '6mo'
				WHEN '630216' THEN '6mo'
				WHEN '157608' THEN '6mo'
				WHEN '4726080' THEN '6mo'
				WHEN '52536' THEN '-'
				WHEN '1575360' THEN '-'
				WHEN '1050240' THEN '-'
				WHEN '210072' THEN '6mo'
				WHEN '787680' THEN '-'
				WHEN '105036' THEN '-'
				WHEN '105072' THEN '6mo'
				ELSE convert(varchar, ((order_detail.qty_os * lens_qty_val * contactinventory.wearing_schedule) + (order_detail.qty_od * lens_qty_val * contactinventory.wearing_schedule)))
				--((order_detail.qty_os * lens_qty_val * isnull((select systemdesc from domain where domainid = contactinventory.wearing_schedule),0)) + (order_detail.qty_od * lens_qty_val * isnull((select systemdesc from domain where domainid = contactinventory.wearing_schedule),0)))
				END AS 'Supply'
	--(order_detail.qty_os * lens_qty_val) + (order_detail.qty_od * lens_qty_val) as 'Total Lenses',
	--order_detail.qty_od + order_detail.qty_os as 'Total Bxs'
from order_detail, orders, contactinventory, id_units
where orders.ordertypeid in (953)
	and orders.orderid = order_detail.orderid
	--and order_detail.qty_od is not null 
	--and order_detail.qty_os is not null
	and (odcontactid = contactinventory.contactid OR oscontactid = contactinventory.contactid)
	and orderstatusid not in (24,26,2944,1141,69)
	and contactinventory.lens_qty_id = id_units.lens_qty_id
	and orderdate between @DateFrom and @DateTo
order by orderdate asc, orderid asc
select
orders.orderdate,
orders.patientid,
orders.orderid,
order_detail.odlensname,
order_detail.qty_od,
order_detail.oslensname,
order_detail.qty_os,
order_detail.qty_od + order_detail.qty_os as 'Total Qty',
--Just a blank column
'' as 'Supply Size'
from order_detail, orders
--Soft lenses only
where ordertypeid in (953)
and orders.orderid = order_detail.orderid
and (order_detail.clensodname is not null or order_detail.clensosname is not null)
--Fix date
and orderdate between '2016-02-01' and '2016-03-01'

以上是关于sql 隐藏镜头报告 - 生成订单数量报告的主要内容,如果未能解决你的问题,请参考以下文章

sql server 数据驱动订阅停止发送

删除报告上自动生成的标签是不是会增加该报告上使用的字段数量?

PL/SQL 触发器练习

如何根据总订单价值和邮政组获取报告

访问报告 - 基于数据隐藏字段、标签和其他元素

如何根据 startdate 和 enddate 参数隐藏 s-s-rs 报告生成器中的列?