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

麻烦给看看这个oracle语句该怎样写

表名:gk_record_new(这是一个考勤表,所有员工的考勤数据都存放在这个表里,主键为卡号和时间)

表结构:
卡号:NUMBER(10)
基站:VARCHAR2(20)
时间:DATE
出入标志:VARCHAR2(1)

表数据

卡号 基站 时间 出入标志
123 1# ... I
456 2# ... I
123 1# ... O


从这个表里获取当前在班上的人

我写的语句是:
select * from (select * from gk_record_new where 出入标志='I' order by 时间 desc) where rownum<=4 order by 时间 desc

其中“4”是所有进入的人员减去出去的差值,不过这样写好像不对

请高手帮帮忙 愁死了....







select * from
(select distinct id,
  (select max(date) from t where t.id = id and type = 'I') din,
  (select max(date) from t where t.id = id and type = 'O') dout
from t)
where din > dout and din < sysdate;

select * from (
  select cardno,mod(count(cardno),2) num from GK_RECORD_NEW group by cardno
) t, GK_RECORD_NEW g where t.num = 1 and g.io='I' and t.cardno = g.cardno

select *
  from (
select 卡号,基站,时间,出入标志,row_number()over(partition by 卡号 order by 时间 desc) rn from gk_record_new )
where rn=1 and 出入标志='I'
;

楼主的
select * from (select * from gk_record_new where 出入标志='I' order by 时间 desc) where rownum <=4 order by 时间 desc 
感觉是不对 首先查出


相关问答:

PHP 连接Oracle 出错

<?php
  getenv("ORACLE_HOME");
  $conn=ocilogon("test","test","test_db");
  if($conn)  
  echo success;  
&nb ......

介绍Oracle和mysql的书 - Oracle / 非技术区

我对SQL SERVER和ACCESS比较熟,所以数据库的通用基础东西可以说都掌握的差不多了,我现在想要的就是以上两数据库的独特之处的介绍和应用介绍。
另外书最好对应最新版本 oracle是11g吧 10的也行;mysql是5.1吧
谢 ......

求助ORACLE批量清除表数据的问题 - Oracle / 开发

比如我有testA、testB、testC三个表
我现在需要写一个批处理或者脚本给别人 作用就是执行这段语句可以清除这三个表里面的数据 就是一个初始化的意思
哪位高人帮助下啊 一个数据库小白在此求救啦
SQL code:
......

imp 导入 oracle 问题

导出、导入都是 oracle 10g 。

在导入过程中出现如下情况:

IMP-00017: 由于 ORACLE 错误 6550, 以下语句失败:
"DECLARE  SREC DBMS_STATS.STATREC; BEGIN SREC.MINVAL := '4E014E50 ......

是oracle的bug么?散分了! - Oracle / 基础和管理

本来要写个update语句
update table_a A
  set A.flag=1
  where A.id in (select B.id from table_b B)
结果误写成
update table_a A
  set A.flag=1
  where ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号