sql 視圖 按where條件多個欄位取一個,sqlwhere

來源:互聯網
上載者:User

sql 視圖 按where條件多個欄位取一個,sqlwhere


首先介紹一下 Case ..When...Then..End  的用法:

CASEJiXiaoFind_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

如何做呢?

****************************************************************************

具體做法:

視圖中加中紅字部分,即可。

 

 


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.