网易模拟器,pgd-619,小泽玛丽亚电影
我们在开发过程中,经常需要针对一列,基于条件逻辑来返回一个值,那么,这时候就需要使用到case表达式了。
例如,以下对products表的查询就在select语句中使用了case表达式,以生成用于描述categoryid列取值的信息。
sql代码如下:
-- 设置数据库上下文 use tsqlfundamentals2008; go select productid,productname,categoryid, case categoryid when 1 then 'beverages' when 2 then 'condiments' when 3 then 'dairy products' when 4 then 'confections' when 5 then 'grains/cereals' when 6 then 'meat/poultry' when 7 then 'produce' when 8 then 'seafood' else 'unkown category' end as categoryname from production.products;
查询结果:
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
数据库SQL---数据库、基本表、视图、索引的定义、修改、删除
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (上)
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (下)
网友评论