我正在尝试合并表中的两条记录,然后将其表示为新记录。
这是我的桌子:
date|flag|bu|volume|calls
14-Nov-21,1,accounting,50,10
14-Nov-21,2,InfoSec,111,106
14-Nov-21,3,IT,500,100
14-Nov-21,4,management,70,60
14-Nov-21,5,consulting,5,45
当我运行查询时,我希望表看起来像这样:
date|flag|bu|volume|calls
14-Nov-21,1,accounting,50,10
14-Nov-21,2,InformationTechnology,611,206
14-Nov-21,4,management,70,60
14-Nov-21,5,consulting,5,45
如您所见,我将 InfoSec 和 IT 记录合并为一个新记录。关于如何做到这一点的任何想法或建议?
这是我的查询到目前为止的样子:
with bc as (select * from table1)
select date,flag,case when bu='IT' and bu='InfoSec' then 'InformationTechnology' else bu end as bu,volume,calls