44-2·100 sql server case when 判断计算 城市案例02 and 善反观
case when定义
用于判断计算条件列表的表达式,并且返回可能的结果之一.。简单say 就是如果就的意思.
The expression used to judge the list of calculation conditions and return one of the possible results. Simple say means if
--st表 learn and write 02 根据城市返回结果。如果在北京,就返回结果 梦想高薪. 如果在二线青岛,就返回结果文字为 糊口薪水, 如果在县城,就返回文字为 混吃等死. select * from st; select count(*) as 汇总return表的全部数量 from st; --case when 判断计算表达式 write02 select stname, case when city='北京' then '梦想高薪' when city='青岛' then '糊口薪水' --注意: 首先必须有这个如果的条件存在于表中,然后后面的是现实中自定义的文字, 现实项目中,需要展示的文字值内容. --执行逻辑是,先查询到这个when 如果条件的数据. 然后是后面的需求自定义文字内容的显示. --major一点say,这个或许就是交互的过程,已经定义好的表值数据与客户需求值内容交互的过程. when city='县城乡镇' then '混吃等死' else 'return others' end as 结果列 from st;
效果
反观您自个,不就是混吃等死的收入水平吗? yes,然后呢?