gpt4 book ai didi

sql - Oracle 查询合并行为一

转载 作者:行者123 更新时间:2023-12-02 03:07:44 25 4
gpt4 key购买 nike

我有一个表,其中显示 in_time 和 out_time,并在单独的行中显示门编号,但我想将其显示在一行中,因此我需要将两行合并为一行,这是此结果

   | EMPID |                IN_TIME |               OUT_TIME | IN_GATE | OUT_GATE |
|-------|------------------------|------------------------|---------|----------|
| 124 | 01-12-2019 08:49:35 AM | | 4 | |
| 124 | | 01-12-2019 06:53:03 PM | | 5 |
| 125 | 01-12-2019 07:49:35 AM | | 4 | |
| 125 | | 01-12-2019 05:53:03 PM | | 5 |

这是我所期望的

   | EMPID |                IN_TIME |               OUT_TIME | IN_GATE | OUT_GATE |
|-------|------------------------|------------------------|---------|----------|
| 124 | 01-12-2019 08:49:35 AM | 01-12-2019 06:53:03 PM | 4 | 5 |
| 125 | 01-12-2019 07:49:35 AM | 01-12-2019 05:53:03 PM | 4 | 5 |

能否请您给出解决方案

最佳答案

您可以尝试使用group byaggregation

<强> demo

select empid, max(in_time) as in_time,max(out_time) as out_time,
max(in_gate) as in_gate,max(out_Gate) as out_Gate
from tablename
group by empid

关于sql - Oracle 查询合并行为一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59728295/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com