这个语句怎么写呀!请高手解答

[复制链接]
查看11 | 回复8 | 2008-1-10 16:37:46 | 显示全部楼层 |阅读模式
idxh
time
131232008-1-10 16:37:46
231252008-1-10 16:40:22
331262008-1-10 16:51:46
431302008-1-10 17:00:47
531202008-1-10 16:31:05
631272008-1-10 16:54:27
731212008-1-10 16:35:25
831282008-1-10 16:55:31
931292008-1-10 16:57:34
1031162008-1-10 15:56:30
1131172008-1-10 15:58:00
1231242008-1-10 16:39:55
1331142008-1-10 15:44:59
1431152008-1-10 15:45:46
1531052008-1-10 15:41:48
1631062008-1-10 15:41:48
1731032008-1-10 15:41:48
1831042008-1-10 15:41:48
1931072008-1-10 15:41:48
2031082008-1-10 15:41:48
2131092008-1-10 15:41:48
2231102008-1-10 15:41:48
2331112008-1-10 15:41:48
2431122008-1-10 15:41:48
2531132008-1-10 15:41:48
2631312008-1-10 17:01:54
2731222008-1-10 16:36:33
2831322008-1-10 17:02:18
2930992008-1-9 16:47:15

求助一个语句的写法,红色的为日期是一样的,
我现在要取出这样一个记录:就是说红色的,随便去一条出来,再加上日期不是一样的
结果是:
idxh
time
131232008-1-10 16:37:46
231252008-1-10 16:40:22
331262008-1-10 16:51:46
431302008-1-10 17:00:47
531202008-1-10 16:31:05
631272008-1-10 16:54:27
731212008-1-10 16:35:25
831282008-1-10 16:55:31
931292008-1-10 16:57:34
1031162008-1-10 15:56:30
1131172008-1-10 15:58:00
1231242008-1-10 16:39:55
1331142008-1-10 15:44:59
1431152008-1-10 15:45:46
1531132008-1-10 15:41:48
1631312008-1-10 17:01:54
1731222008-1-10 16:36:33
1831322008-1-10 17:02:18
1930992008-1-9 16:47:15
这个怎么写呀!
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
回复下哦!
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
能不能写详细点,我是个初学者
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
select empno,deptno,sal from (
select empno,deptno,sal,row_number() over(partition by dno order by eno) rn from emp )where rn=1
大概是这意思?
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
不行的!我试了,rn=1,但是我相同的时间哪个记录好多呀!
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
select * from (select id,xh,time,row_number() over(partition by time order by id desc) r from table_name) where r=1
如果你是要时间一致的记录只显示一条的话,这条是可行的
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
select max(xh),time
from table_name
group by time
[ 本帖最后由 ts_keta 于 2008-1-11 11:39 编辑 ]
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
可以了!谢谢dino623了!也谢谢其他人哦!
回复

使用道具 举报

千问 | 2008-1-10 16:37:46 | 显示全部楼层
SQL> set wrap off
SQL> select * from test;
ID XH TIME
---------- ---------- ----------
1 3111 07-1月 -08
2 3112 07-1月 -08
3 3113 07-1月 -08
4 3114 07-1月 -08
5 3114 07-1月 -08
6 3114 07-1月 -08
7 3114 07-1月 -08
8 3118 07-1月 -08
已选择8行。
SQL> select * from (
2select id,xh,time ,row_number() over(partition by xh,time orderby id) cn
from test ) where cn
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行