sql视图where条件多字段取一语句
首先,来看case ..when...then..end 语句用法:
case jixiaofind_rowid
when '1' thenjixiao_money1
when '2' then jixiao_money2
when '3' then jixiao_money3
when '4' then jixiao_money4
else jixiao_money5
end
举例:
上图是一个视图的截图,在 表b 中添加一个字段 jixiao_money(绩效金额);
如果
jixiaofind_rowid=1 则 jixiao_money=jixiao_money1
jixiaofind_rowid=1 则 jixiao_money=jixiao_money1
jixiaofind_rowid=1 则 jixiao_money=jixiao_money3
jixiaofind_rowid=1 则 jixiao_money=jixiao_money1
jixiaofind_rowid=1 则 jixiao_money=jixiao_money1
实现方法,视图中加上图中红字部分: