My table contains a column called BATCH_DATE
, and a calculated column that returns the MIN of BATCH_DATE, called MIN_BATCH_DATE
.
我的表包含一个名为BATCH_DATE的列,以及一个返回BATCH_DATE MIN的计算列,名为MIN_BATCH_DATE。
I need a new column CHECK
that gets a value of A1 when the BATCH_DATE
is the same as MIN_BATCH_DATE
, otherwise give it a value of B1.
我需要一个新的列CHECK,当BATCH_DATE与MIN_BATCH_DATE相同时获取值A1,否则给它一个值B1。
I was wondering what the best way to tackle this would be?
我想知道解决这个问题的最佳方法是什么?
I want something like this
我想要这样的东西
[BATCH_DATE] [BATCH_DATE_MIN] [CHECK]
2007-05-01 2007-05-01 A1
2007-05-01 2007-02-01 B1
1 个解决方案
#1
0
Try something like:
尝试以下方法:
SELECT (CASE WHEN BATCH_DATE = MIN_BATCH_DATE THEN 'A1'
ELSE 'B1'
END)CHECK_DT
#1
0
Try something like:
尝试以下方法:
SELECT (CASE WHEN BATCH_DATE = MIN_BATCH_DATE THEN 'A1'
ELSE 'B1'
END)CHECK_DT