如果then语句,则条件格式化

时间:2016-05-26 16:31:58

标签: sql excel conditional ssms-2014

我试图获得excel中的'嵌套if'函数来在查询中进行表达。查询的目标是创建一个视图,以便我可以比较两组数据。

如果在excel中,公式将如下所示:= IF(condition1 = 0,condition2,IF(condition2 = 0,condition3,condition1))。

我不断收到此错误消息:

我尝试使用的查询语言是:

  func viewDidLoad(){

      super.viewDidLoad()

      tableView.rowHeight = UITableViewAutomaticDimension
      tableView.estimatedRowHeight = 44 //  >= 2
    }     


  func getTableViewHeight()->CGFloat{

      tableView.reloadData()
      tableView.layoutIfNeeded()

      return tableView.contentSize.height + tableView.contentInset.bottom + tableView.contentInset.top
    }

1 个答案:

答案 0 :(得分:0)

两件事:

  1. 而不是TotalCash=as TotalCash放在案例陈述中的end之后。

  2. 案例逻辑已关闭。如果兑现<> 0和[现金柜台现金] = 0它将返回[现金柜台现金支出]我认为不是想要的。

  3. 所以请使用:

     drop view danburycomp 
    go
    create view danburycomp as
    select *,
    case 
        when[Cash Out]=0 and [Cash Counter Cash In]<>0 then [Cash Counter Cash In] 
        when [Cash Out]=0 and[Cash Counter Cash In]=0 then [Cash Counter Cash Out] 
        else [Cash Out]
    end as TotalCash
    from [Trans Jan-Mar2016]
    where [Account Number] in ('UNIQUEID1', 'UNIQUEID2')
    and ([Cash Into Trans] !=0 or [Cash Out]!=0)
    and [Date Time Trans] between '2016-01-29' and '2016-02-24'