日期:2014-05-17 浏览次数:20582 次
select * from(
select
r.result_id as result_id,
e.measure_type as measure_type,
e.equip_name as equip_name,
isnull(d.dept_name,de.dept_name) as dept_name,
e.spec as spec,
case
when eq.sn is not null then eq.sn
else e.fact_no end
as fact_no,
r.measure_date as measure_date,
r.measure_unit as measure_unit,
r.measure_result as measure_result,
r.equip_valid_date as equip_valid_date,
r.cert_no as cert_no,
r.measure_fee as measure_fee,
r.byhand_opr as byhand_opr,
case when eq.sn is not null then eq.sn
else e.sn end as sn,f.short_name,e.equip_no
from ams_measure_result r
left join ams_measuretype_equips e on r.equip_id = e.equip_id
left join t_department de on de.dept_id=e.dept_id
left join ams_factory f on f.fact_id=e.product_id
left join
(select dept_name,dept_id,equip_id from ams_equip_dept where end_date is null ) d on e.equip_id = d.equip_id
left join ams_equip eq on r.equip_id=eq.equip_id ) mr
where 1 = 1 --这里不知道怎么写...//select equip_id from ams_measure_result inner join
order by mr.measure_date desc,mr.measure_type desc,mr.equip_name desc
select * from(
select
r.result_id as result_id,
e.measure_type as measure_type,
e.equip_name as equip_name,
isnull(d.dept_name,de.dept_name) as dept_name,
e.spec as spec,
case
when eq.sn is not null then eq.sn
else e.fact_no end
as fact_no,
r.measure_date as measure_date,
r.measure_unit as measure_unit,
r.measure_result as measure_result,
r.equip_valid_date as equip_valid_date,
r.cert_no as cert_no,
r.measure_fee as measure_fee,
r.byhand_opr as byhand_opr,
case when eq.sn is not null then eq.sn
else e.sn end as sn,f.short_name,e.equip_no
from ams_measure_result r
left join ams_measuretype_equips e on r.equip_id = e.equip_id
&