数据举例如下: 列1 列2 列3 列4 a b c 1 a b c 2 d e f 1 d e f 2 d e f 3我想从这个表里取出 列1 列2 列3 列4 a b c 2 d e f 3
select 列1, 列2 ,列3 ,count(*) from table group by 列1, 列2, 列3 很基础呀,要加强学习了
数据举例如下: 列1 列2 列3 列4 a b c 1 a b c 2 d e f 1 d e f 2 d e f 8我想从这个表里取出 列1 列2 列3 列4 a b c 2 d e f 8如果把3改成8,上述方法就不灵啦
select 列1, 列2 ,列3 ,max(列4) from table group by 列1, 列2, 列3
select 列1,列2,列3,max(列4) from tb group by 列1,列2,列3select 列1,列2,列3,列4 from (select 列1,列2,列3,列4, row_number() over(partition by 列1,列2,列3,rowid order by 列4 desc) rn from tb) a where a.rn=1
没看到你表结构和数据分布,所以不能根据你具体问题来答,贴出你的表结构和数据吧 以及你想要的结果
看了你的需求估计分析函数可以满足 row_number()
列1 列2 列3 列4
a b c 1
a b c 2
d e f 1
d e f 2
d e f 3我想从这个表里取出
列1 列2 列3 列4
a b c 2
d e f 3
from table
group by 列1, 列2, 列3
很基础呀,要加强学习了
列1 列2 列3 列4
a b c 1
a b c 2
d e f 1
d e f 2
d e f 8我想从这个表里取出
列1 列2 列3 列4
a b c 2
d e f 8如果把3改成8,上述方法就不灵啦
from table
group by 列1, 列2, 列3
select 列1,列2,列3,max(列4)
from tb
group by 列1,列2,列3select 列1,列2,列3,列4
from (select 列1,列2,列3,列4,
row_number() over(partition by 列1,列2,列3,rowid order by 列4 desc) rn
from tb) a
where a.rn=1