本网站上的第一篇文章,请让我知道它是否配方齐全。
某些情况:我工作的地方有一个接机柜台,我们希望看到三个单独交易的 MIN 时间戳。输入的时间,首次挑选的时间,发货的时间是三个变量。它要求我在同一列中 MIN 三个单独的时间,每个时间条件不同。这就是我陷入困境的地方:
SELECT CONTROL_NUMBER, MIN(START_TRAN_TIME) AS START_T,
MIN(START_TRAN_TIME) AS PICK_T,
MIN(START_TRAN_TIME) AS SHIP_T
FROM T_TRAN_LOG
WHERE WH_ID = 'W376' ....
时间戳由事务类型(TRAN_TYPE)变量决定。 - START_T列是TRAN_TYPE等于' 961' - PICK_T列是tran_type等于' 306' - SHIP_T列是tran_type等于' 340'
的列tran type start_tran_time
340 6/18/2018 8:14
306 6/18/2018 8:10
我不知道如何从这里开始,我已经自学了很多SQL,所以非常感谢任何帮助。
谢谢,
答案 0 :(得分:1)
您可以使用案例何时选择不同的tran类型:
org.tensorflow.TensorFlowException: Op type not registered
'NonMaxSuppressionV3' in binary running on localhost. Make sure the Op
and Kernel are registered in the binary running in this process. Note
that if you are loading a saved graph which used ops from tf.contrib,
accessing (e.g.) `tf.contrib.resampler` should be donebefore importing the
graph, as contrib ops are lazily registered when the module is first accessed.
答案 1 :(得分:1)
合并case/when
和min
select
CONTROL_NUMBER,
Min(case when tran_type = '961' then START_TRAN_TIME else null end) AS START_T,
Min(case when tran_type = '306' then START_TRAN_TIME else null end) AS PICK_T,
Min(case when tran_type = '340' then START_TRAN_TIME else null end) AS SHIP_T,
from
T_TRAN_LOG
where
WH_ID = 'W376'
Group by
CONTROL_NUMBER
答案 2 :(得分:0)
我认为你可以尝试这样的事情:
SELECT CONTROL_NUMBER
from T_TRAN_LOG pivot
(
MIN(START_TRAN_TIME) for PICK_T
in('961' as "START_T",
'306' as "PICK_T" ,
'340' as "SHIP_T")
)
where WH_ID = 'W376' ...
我不知道这是否是您问题的答案,因为我没有完整的数据。