示例 CatTerm_id = 613
SELECT
CatalogTerm_Id
,CatalogResolution_Id
,Catalogresolution.name
,CatalogRegulation.Threshold
,OptionItem.name
,ApprovalType =
CASE
WHEN OptionItem.name LIKE 'Corporate' THEN 1
WHEN OptionItem.name LIKE 'GEO' THEN 2
WHEN OptionItem.name LIKE 'Country/Area' THEN 3 ELSE 4
END
FROM CatalogResolution, CatalogRegulation, OptionItem
WHERE CatalogTerm_Id = 613
AND CatalogResolution.ID = CatalogResolution_id
AND OptionItem.ID = CatalogRegulation.Level_Id
AND type_id IN (645)
AND CatalogResolution.IsDeleted = 0
AND CatalogRegulation.IsDeleted = 0
ORDER BY CatalogTerm_Id
输出 :
613 1051
Country/Area 3
613 1053
Geo 2
613 1054
Country/Area 3
输出:国家/地区。
但是显示器应该显示 GEO,然后我可以将它扩展到整个列表而不指定 CatTerm_id
SELECT TOP 1
CatalogTerm_Id
,CatalogResolution_Id
,Catalogresolution.name
,CatalogRegulation.Threshold
,OptionItem.name
,ApprovalType =
CASE
WHEN OptionItem.name LIKE 'Corporate' THEN 1
WHEN OptionItem.name LIKE 'GEO' THEN 1
WHEN OptionItem.name LIKE 'Country/Area' THEN 1 ELSE 4
END
FROM CatalogResolution, CatalogRegulation, OptionItem
WHERE CatalogTerm_Id = 613
AND CatalogResolution.ID = CatalogResolution_id
AND OptionItem.ID = CatalogRegulation.Level_Id
AND type_id IN (645)
AND CatalogResolution.IsDeleted = 0
AND CatalogRegulation.IsDeleted = 0
ORDER BY CatalogTerm_Id
613 1051
国家/地区 1
这不是我想要的我想要的“GEO”