在 Mysql 中,我有 fdllowing 查询以及下面的结果
drop table tab1;
CREATE TEMPORARY TABLE tab1
(col1 integer,col2 integer(10),col3 varchar(10),col4 integer)engine=memory
insert into tab1
values(100,1,'Hello',9);
insert into tab1
values(200,1,'HelloWrld',8);
insert into tab1
values(300,1,'HelloTher',7);
insert into tab1
values(400,2,'HiThere',6);
insert into tab1
values(500,3,'Howdy',5);
insert into tab1
values(600,3,'Hiya',4);
select col1,col2,col3,col4,min(col4)
from tab1
group by col2
'100', '1', 'Hello', '9', '7'
'400', '2', 'HiThere', '6', '6'
'500', '3', 'Howdy', '5', '4'
在 Oracle 中,我想要与 Mysql 相同的结果
with tab1 as (
select 100 col1, 1 col2, 'Hello' col3,9 col4 from dual
union all
select 200 col1, 1 col2, 'HelloWrld' col3,8 col4 from dual
union all
select 300 col1, 1 col2, 'HelloTher' col3,7 col4 from dual
union all
select 400 col1, 2 col2, 'HiThere' col3,6 col4 from dual
union all
select 500 col1, 3 col2, 'Howdy' col3,5 col4 from dual
union all
select 600 col1, 3 col2, 'Hiya' col3,4 col4 from dual
)
select min(col1),col2,min(col3),col4,min(col4)
from tab1
group by col2,col4
Result I get is this
MIN(COL1) COL2 MIN(COL3) COL4 MIN(COL4)
---------- ---------- --------- ---------- ----------
100 1 Hello 9 9
200 1 HelloWrld 8 8
500 3 Howdy 5 5
600 3 Hiya 4 4
300 1 HelloTher 7 7
400 2 HiThere 6 6
我想要的是这个
'100', '1', 'Hello', '9', '7'
'400', '2', 'HiThere', '6', '6'
'500', '3', 'Howdy', '5', '4'
我如何在 Oracle 中实现 Mysql like group by 我无法得到这个,这是我试图解决的长查询的一部分