(CASE WHEN a."买入业务归属机构 " != a."卖出业务归属机构" THEN (a."买入利率" - a."卖出利率" - a."卖出操作员分成")ELSE a."买入利率" - a."卖出利率" END)as "卖断利差"
时间: 2023-11-20 19:59:51 浏览: 29
这是一段SQL语句,使用了CASE WHEN语句进行条件判断,根据条件返回不同的结果。具体来说,当“买入业务归属机构”不等于“卖出业务归属机构”时,返回“买入利率”减去“卖出利率”再减去“卖出操作员分成”的结果,否则返回“买入利率”减去“卖出利率”的结果,最终将结果命名为“卖断利差”。
由于这是一段SQL语句,需要在数据库中执行才能得到结果。如果你需要更详细的解释或者如何在数据库中执行这段语句,请提供更多的上下文信息。
相关问题
case when a.id='1' from
It looks like your SQL statement is incomplete. The `CASE` statement is used to conditionally return a value based on one or more conditions. However, in your example, you only have the beginning of the statement (`CASE WHEN a.id='1' FROM`).
Assuming you want to return a specific value when `a.id` is equal to `'1'`, the correct syntax would be:
```
SELECT CASE WHEN a.id = '1' THEN 'Value when ID is 1' ELSE 'Value when ID is not 1' END as my_column
FROM my_table a
```
In this example, the `CASE` statement checks if `a.id` is equal to `'1'`. If it is, the value `'Value when ID is 1'` is returned. If it is not, the value `'Value when ID is not 1'` is returned. The result is returned as a column named `my_column` from the table `my_table` (which you will need to replace with your actual table name).
case a.TC_SGT04 when (CHARINDEX (a.TC_SGT04,d.DayClass)!=0) then '白班' when (CHARINDEX (a.TC_SGT04,d.NightClass)!=0) then '夜班'怎么修改呢
这段代码是一个SQL Server的CASE语句,它的作用是根据a.TC_SGT04的值判断是白班还是夜班并返回对应的字符串。
如果你想修改这段代码,可以根据具体的需求来修改判断条件和返回值,例如:
- 如果需要增加一种班次类型,可以在这个CASE语句里增加一个WHEN-THEN分支。
- 如果需要根据其他字段或条件来进行判断,可以在CASE语句里增加相关的逻辑。
- 如果需要修改返回值,可以直接修改对应的字符串。
举个例子,如果你需要在夜班的基础上再增加一个中班,可以修改代码如下:
```
case a.TC_SGT04
when (CHARINDEX (a.TC_SGT04,d.DayClass)!=0) then '白班'
when (CHARINDEX (a.TC_SGT04,d.NightClass)!=0) then '夜班'
when (CHARINDEX (a.TC_SGT04,d.MiddleClass)!=0) then '中班'
end
```
这样就可以根据a.TC_SGT04的值判断是白班、夜班还是中班并返回对应的字符串了。