您可以使用子选择来转换
department_id
文本格式如下:
select convert(varchar(15), doc_Date, 103) Doc_Dates,
(select type_desc from type_mst_a where master_mkey = department_id),
...
或者,您可以加入表格
type_mst_a
.
select convert(varchar(15), doc_Date, 103) Doc_Dates,
department_id,
text.type_desc,
case outward_Type when 'N' then 'None' when 'P' then 'Private' when 'C' then 'Confidential' end [Type],
convert(varchar(15), ref_date, 103) Ref_dates,
convert(varchar(15), Updated_Bill_Date,103) Updated_Bill_Dates,
convert(varchar(15), Due_Date, 103) Due_dates,
*
from view_A_Inward_Doc_Tracking_Hdr INWARD
left outer join type_mst_a text on text.master_mkey = department_id
where INWARD.delete_flag = 'N'
and mkey = 227381
外部联接保证,如果找不到合适的文本,查询结果不会消失。