上下文绑定语法[重复](Context binding syntax [duplicate])
这个问题在这里已有答案:
- 解释封装的匿名函数语法 9答案
让我们假设我们有
function () {}.bind(null);
和
(function () {}).bind(null);
为什么第一个在开发人员控制台中不起作用(它会引发语法错误),但它们都在代码中工作(网站中的“.js”文件)。
This question already has an answer here:
Lets assume we have
function () {}.bind(null);
and
(function () {}).bind(null);
Why the first one doesn't work in developer console (it throws syntax error) but both of them work in code (".js" file in website).
原文:https://stackoverflow.com/questions/37962387
最满意答案
...当子串(B.gl_accountcode,9,2)='60'作为条件1时,以及当(B.gl_accountcode)='40000000003102'和子串(B.gl_accountcode,9,2)='60'时与条件2相同的GL参考。
当子串(B.gl_accountcode,9,2)不是'60'并且(B.gl_accountcode)='40000000003102'时,我不想在MOE列中填充'60'
更容易说是......
60 when substring(x) = '60' OR (B.gl_accountcode = 'y' and substring(x) = '60') (...and not when (B.gl_accountcode = 'y' and substring(x) <> '60')
这基本上是
substring(x) = '60'
所以你的最后陈述是:
select RTRIM(LTRIM(B.gl_accountcode)) as 'GL AccountCode', RTRIM(LTRIM(B.gl_reference)) as 'GL Reference', RTRIM(LTRIM(B.gl_subledger_code)) as 'GL Subledger Code', CASE WHEN substring(B.gl_accountcode,9,2) = '60' THEN '60' ELSE '' END MOE from pronto_NZD_GLTransUnion B where B.gl_reference in ( '00025928', '00001064') order by B.gl_reference, B.gl_accountcode
编辑:当我在等待你想要的结果时,这可能是你想要的吗?
select RTRIM(LTRIM(B.gl_accountcode)) as 'GL AccountCode', RTRIM(LTRIM(B.gl_reference)) as 'GL Reference', RTRIM(LTRIM(B.gl_subledger_code)) as 'GL Subledger Code', CASE WHEN substring(B.gl_accountcode,9,2) = '60' THEN '60' WHEN gl_accountcode = '40000000003102' AND EXISTS (SELECT 1 FROM pronto_NZD_GLTransUnion a WHERE substring(a.gl_accountcode,9,2) = '60' AND a.gl_reference = B.gl_reference) THEN '60' ELSE '' END MOE from pronto_NZD_GLTransUnion B where B.gl_reference in ( '00025928', '00001064') order by B.gl_reference, B.gl_accountcode
- 看到它在sqlfiddle中工作
... 60 when substring(B.gl_accountcode,9,2) = '60' as condition 1 and also when (B.gl_accountcode) = '40000000003102' and substring(B.gl_accountcode,9,2) = '60' for same GL Reference as condition 2.
I don't want to populate '60' in MOE column when substring(B.gl_accountcode,9,2) is not '60' and (B.gl_accountcode) = '40000000003102'
Easier said is...
60 when substring(x) = '60' OR (B.gl_accountcode = 'y' and substring(x) = '60') (...and not when (B.gl_accountcode = 'y' and substring(x) <> '60')
Which basically is
substring(x) = '60'
So your final statement is:
select RTRIM(LTRIM(B.gl_accountcode)) as 'GL AccountCode', RTRIM(LTRIM(B.gl_reference)) as 'GL Reference', RTRIM(LTRIM(B.gl_subledger_code)) as 'GL Subledger Code', CASE WHEN substring(B.gl_accountcode,9,2) = '60' THEN '60' ELSE '' END MOE from pronto_NZD_GLTransUnion B where B.gl_reference in ( '00025928', '00001064') order by B.gl_reference, B.gl_accountcode
EDIT: While I'm waiting for your desired result, could this be what you're looking for?
select RTRIM(LTRIM(B.gl_accountcode)) as 'GL AccountCode', RTRIM(LTRIM(B.gl_reference)) as 'GL Reference', RTRIM(LTRIM(B.gl_subledger_code)) as 'GL Subledger Code', CASE WHEN substring(B.gl_accountcode,9,2) = '60' THEN '60' WHEN gl_accountcode = '40000000003102' AND EXISTS (SELECT 1 FROM pronto_NZD_GLTransUnion a WHERE substring(a.gl_accountcode,9,2) = '60' AND a.gl_reference = B.gl_reference) THEN '60' ELSE '' END MOE from pronto_NZD_GLTransUnion B where B.gl_reference in ( '00025928', '00001064') order by B.gl_reference, B.gl_accountcode
- see it working live in an sqlfiddle
相关问答
更多-
select Col1, Col2, Col3, Col4, CASE Col4 WHEN 'casea' then col1*col2 WHEN 'caseb' then col1*col3 WHEN 'casec' then col2*col3 END AS Total FROM YourTable select Col1, Col2, Col3, Col4, CASE Col4 WHEN 'casea' then col ...
-
> how do I tell Hybris that the combination of the > columns Firstname + Lastname must be unique? 将unique关键字添加到组合键的每个字段中 INSERT_UPDATE SLEmployee;Firstname[unique=true];Lastname[unique=true];Function; > how do I tell Hybris that the combination of the ...
-
将每个非varchar列转换为varchar,然后使用'+'运算符连接。 应该这样做。 编辑后 update K2_Data set Long_Desc = (cast(PremiseRef as varchar) +','+BuildRef+','+BlockRef+','+Location+','+cast(ItemRef as varchar)+','+cast(Quant as varchar)+','+Life) where k2_ref = 431578 第二次编辑后 update K2_D ...
-
以下内容可以让您接近您所寻找的内容: SELECT a.plant, SUBSTR(a.completed_ts, 1, 4) wo_year, a.asset_nbr asset, c.asset_desc descr, c.dept dept, COALESCE(department_rate.RATE, plant_default_rate.RATE, 0) AS RATE, COUNT(DISTINCT a.work ...
-
如果你只减去1你可以使用dplyr::group_indices library(dplyr) df %>% mutate(id = group_indices(., country, region_country_a, region_country_b, region_country_c)-1) %>% head(5) # country region_country_a region_country_b region_country_c id # 1 c ...
-
在基于派生列的其他列的值组合中构造值(Construct values in derived column based combination of values from another columns)[2023-04-29]
...当子串(B.gl_accountcode,9,2)='60'作为条件1时,以及当(B.gl_accountcode)='40000000003102'和子串(B.gl_accountcode,9,2)='60'时与条件2相同的GL参考。 当子串(B.gl_accountcode,9,2)不是'60'并且(B.gl_accountcode)='40000000003102'时,我不想在MOE列中填充'60' 更容易说是...... 60 when substring(x) = '60' OR (B. ... -
根据从现有列派生的TRUE / FALSE设置新列值(Set new column value based on TRUE/FALSE derived from existing columns)[2022-10-24]
为什么不使用: DT[, flag := +(from < 6500 & to > 6500)] ()给出条件, +使它成为逻辑整数( 0或1 )。 这给出了与以下相同的结果: DT[, flag := ifelse(from < 6500 & to > 6500, 1, 0)] 另一种可能性(由@Frank建议): DT[, flag := mapply(between,6500,from,to)] 然而, mapply调用导致相当一些开销。 只是使用: DT[, flag := between(6 ... -
数据框,列名由列值和单元格值按条件派生而来(Dataframe with column names derived from column values and cell values by condition)[2022-04-29]
你可以使用函数crosstab ,然后找到更高的值为1并通过astype将其转换为1和0 : dfm = pd.DataFrame({'v' : [44,39,39,8,40,8,15,15],'x':[1,1,1,1,2,2,2,2]}) print dfm v x 0 44 1 1 39 1 2 39 1 3 8 1 4 40 2 5 8 2 6 15 2 7 15 2 df = pd.crosstab(dfm.x, dfm.v) #rename co ... -
根据其他列的唯一组合更改数据框列值(Change the dataframe column values based on unique combination of other columns)[2024-01-30]
让我们使用groupby , transform和first : df.assign(name=df.groupby(['id','code'])['name'].transform('first')) 输出: id code name 0 1 11 a 1 2 12 b 2 1 11 a 3 3 12 d 4 3 7 e 5 2 12 b Let's use groupby, transform, ... -
SSIS派生列圆值(SSIS Derived Column Rounds Values)[2022-03-10]
如果TransTotal是INT ,那么您的代码当前首先执行整数除法( TransTotal / 100 ,意味着8725/100等于87,因为它是整数),然后将其转换为NUMERIC 。 您需要先将TransTotal转换为NUMERIC然后执行除法: ((DT_NUMERIC,10,2) TransTotal) / 100 If TransTotal is an INT, then your code is currently performing first an integer division ...