当前位置:知之问问>百科问答>SQL SELECT语句中嵌入多重选择,用if语句

SQL SELECT语句中嵌入多重选择,用if语句

2024-09-09 21:13:06 编辑:join 浏览量:570

问题补充说明:我是这样写的,不知道哪里错了USE YGGLGOSELECT EmployeeID,Name,Address,DepartmentID= ( IF (SELECT DepartmentID FROM Employees)='1' BEGIN RETURN '财务部' END IF (SELECT DepartmentID FROM Employees)='2' BEGIN RETURN '人力资源部' END IF (SELECT DepartmentID FROM Employees)='3' BEGIN RETURN '经理办公室' END IF (SELECT DepartmentID FROM Employees)='4' BEGIN RETURN '研发部' END IF (SELECT DepartmentID FROM Employees)='5' BEGIN RETURN '市场部' END )FROM Employees

SQL SELECT语句中嵌入多重选择,用if语句

SELECTEmployeeID,Name,Address,

casewhenDepartmentID='1'then'财务部'

whenDepartmentID='2'then'人力资源部'

whenD进亚文厂epartmentID='3'then'经理办公室'

whenDepartmentID='4't得需图几hen'研发部'

whenDepartmentID='5'then'市场部'ENDasDepartmentID

FROMEmployees

标签:语句,多重选择,SQL

版权声明:文章由 知之问问 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.zhzhwenwen.com/answer/336496.html
热门文章