我正在尝试从表T1创建一个select查询,该表有四列,如下所示
我的目标是获得一个选择输出表,其列名为synoynym,如下所示
File_name,'UDAV','Hemat','CCI'
我遇到的挑战是:
UDAV - SELECT agnt_serial_num FROM T1 WHERE agnt_name ='UV inhibitor'
Hemat - SELECT agnt_serial_num FROM T1 WHERE agnt_name ='hematoxylin'
CCI - SELECT concat(agnt_serial_num,'_',agnt_lot_num) FROM T1 WHERE agnt_name ='Carbon Morpher'
这些'agnt_name(s)'中的每一个对于file_name都是唯一的。任何帮助将不胜感激
答案 0 :(得分:0)
也许我想念你的需求
答案 1 :(得分:0)
我猜:
select a.file_name
, a.sn as 'UDAV'
, b.sn as 'Hemat'
, c.sn as 'CCI'
from
( SELECT agnt_serial_num sn FROM T1 WHERE agnt_name ='UV inhibitor' ) a
,( SELECT agnt_serial_num sn FROM T1 WHERE agnt_name ='hematoxylin' )b
,( SELECT concat(agnt_serial_num,'_',agnt_lot_num) sn FROM T1 WHERE agnt_name ='Carbon Morpher' ) c
where a.file_name = b.file_name
and b.file_name = c.file_name