日期:2014-05-17 浏览次数:20758 次
select b.dicname as '样品类别' from kcwms.enoutlist as a,kcwms.dictname as b where b.dicid=a.sampletype and b.dictype in ('SAMPLE','STATE');
------解决方案--------------------
LZ 需要的结果是几列?
如果是两列 做不到你需要的结果 列名不可能变化
------解决方案--------------------
select case when b.dictype='SAMPLE' then b.dicname else '' end as '样品类别'
,case when b.and b.dictype='STATE' then b.dicname else '' end as 物品状态'
from kcwms.enoutlist as a,kcwms.dictname as b
where b.dicid=a.sampletype ;
这样的话就产生了两个列 !楼主参照
------解决方案--------------------
select '' as '物品状态',b.dicname as '样品类别' from kcwms.enoutlist as a,kcwms.dictname as b where b.dicid=a.sampletype and b.dictype='SAMPLE'; union all select b.dicname as '物品状态','' as '样品类别' from kcwms.enoutlist as a,kcwms.dictname as b where b.dicid=a.sampletype and b.dictype='STATE'; 是不是这个意思? when case 也可以实现