首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

希望各位帮下忙,写个sql语句

2012-01-06 
希望各位大虾帮下忙,写个sql语句部门ID员工ID点数00000100000130000000010000022000000002000001100000000

希望各位大虾帮下忙,写个sql语句
部门ID   员工ID   点数
000001   000001   3000
000001   000002   2000
000002   000001   1000
000002   000003   4000

运行完后结果应该是这个样子
员工ID   点数
000001   3000   --> 此员工取部门ID为最小的部门ID
000002   2000
000003   4000
======   有多少个员工ID就显示多少个员工ID

谢谢各位大虾了。小弟谢过了。

[解决办法]
不知道行不行?
select
a.员工ID, 点数
from
table a
where
exists(
select
distinct b.员工ID
from
table b
where
b.部门ID = (
select
min(c.部门ID)
from
table c
where
c.员工ID = b.员工ID
)
and b.员工ID = a.员工ID)
[解决办法]
create table mtest3 (deptId number(10),workUserId number(10),poit number(10));

select workuserid,poit
from(
select workuserid,poit
,row_number()over(partition by workuserid order by deptId ) as rn
from mtest3
)
where rn=1
[解决办法]
xxhsjp()
good
[解决办法]
select 员工ID,点数 from
table t,
(
select 员工ID id,min(部门ID) dep_id from table
group by 员工ID
) v
where t.部门ID=v.dep_id and t.员工ID=v.id

热点排行