易截截图软件、单文件、免安装、纯绿色、仅160KB

求SQL - Oracle / 开发

列A,列B
a1,1
a1,2
a1,3
a2,1
a2,2
a3,1
a4,2
..
..



列A=a1里列B最大的
列A=a2里列B最大的
。。。。
select a ,max(b) as maxb from table group by a

select a, max(b)
from tb
group by a

引用
select a ,max(b) as maxb from table group by a


列很多。
我想写 select * 呢?

SQL code:
select a ,max(b) as maxb from table group by a


引用
引用 1 楼 fardison 的回复:
select a ,max(b) as maxb from table group by a


列很多。
我想写 select * 呢?

用group by 就不能用*

也就是说除了 group by 没有别的办法?


楼上正解
SQL code:
with Table_A as (

select 'a1' a ,1 b from dual
union all
select 'a1' a ,2 b from dual
union all
select 'a1' a ,3 b from dual
union all
select 'a2' a ,1 b from dual
union all
select 'a2' a ,2 b from dual
union all
select 'a3' a ,1 b from dual
union all
select 'a4' a ,2 b from dual

)

SELECT *
from Table_A t1
WHERE EXISTS (SELECT t2.a, max(t2.b)
from Table_A t2
WHERE t2.a=t1.a
GROUP BY t2.a)


相关问答:

Windows 7 怎样安装Oracle - Oracle / 基础和管理

各位大哥,帮个忙。

下个Oracle for vista 版本的安装试试
10G和11G的 
http://www.oracle.com/technology/software/products/database/index.html 
------------------------------------------- ......

[原创] ORACLE 连接字串 - Oracle / 非技术区

假设table01 中有 以下资料
emp_no emp_name
------- ------------
0001 TOM
0002 JOHN
0003 MARY
常用电话 
而我们要得到以下的OUTPUT (或是各种其他的output)
0001,TOM
0002,JOHN ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

Oracle临时表使用问题 - Oracle / 开发

我的处理是这样的:
我有一个很大的数据集合,处于性能方面的考虑需要使用临时表过渡,并且使用分页的方式向临时表中插入数据,数据使用完毕后,删除临时表的数据。
出现的现象:当Oracle重新启动后,第一页插入的 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号