3,499
社区成员
发帖
与我相关
我的任务
分享with t as(
select '张三' username, '固定发票' dl, '50元固定发票' xl, 1001001 bh from dual
union all select '张三' , '固定发票' , '50元固定发票', 1001002 from dual
union all select '张三' , '固定发票' , '50元固定发票', 1001003 from dual
union all select '李四', '固定发票', '50元固定发票' , 1001004 from dual
union all select '李四', '固定发票', '50元固定发票' , 1001005 from dual
union all select '李四', '固定发票', '50元固定发票' , 1001006 from dual
union all select '王五', '固定发票', '50元固定发票' , 1001007 from dual
union all select '王五', '固定发票', '50元固定发票' , 1001008 from dual
)
select username,dl,xl,min(bh),max(bh) from
(select username,dl,xl,bh,bh-row_number() over(partition by username,dl,xl,order by bh xxl from t) group by username,dl,xl,xxl;with t as(
select '张三' username, '固定发票' dl, '50元固定发票' xl, 1001001 bh from dual
union all select '张三' , '固定发票' , '50元固定发票', 1001002 from dual
union all select '张三' , '固定发票' , '50元固定发票', 1001003 from dual
union all select '李四', '固定发票', '50元固定发票' , 1001004 from dual
union all select '李四', '固定发票', '50元固定发票' , 1001005 from dual
union all select '李四', '固定发票', '50元固定发票' , 1001006 from dual
union all select '王五', '固定发票', '50元固定发票' , 1001007 from dual
union all select '王五', '固定发票', '50元固定发票' , 1001008 from dual
)
select username,dl,xl,min(bh),max(bh) from t group by username,dl,xl;
select 名字,发票大类,发票小类,max(发票号),min(发票号)
from table group by 名字,发票大类,发票小类