SQL> select * from student;NAME              AGE
---------- ----------
a                  18
b                  18
c                  18
d                  19
e                  19
f                  19
g                  18
h                  18
i                  18已选择9行。SQL> break on age;
SQL> select * from student;NAME              AGE
---------- ----------
a                  18
b
c
d                  19
e
f
g                  18
h
i已选择9行。SQL> select * from student where age = 18;NAME              AGE
---------- ----------
a                  18
g                  18
已选择2行。
如何实现?--但我现在想要的结果是:SQL> select * from student where age = 18;NAME              AGE
---------- ----------
a                  18
b
c
g
h
i

解决方案 »

  1.   

    说反了,
    现在是
    SQL> select * from student where age = 18;NAME              AGE
    ---------- ----------
    a                  18
    b
    c
    g
    h
    i
    但我想要SQL> select * from student where age = 18;NAME              AGE
    ---------- ----------
    a                  18
    g                  18如何实现?
      

  2.   

    NAME              AGE
    ---------- ----------
    a                  18
    b                  18
    c                  18
    d                  19
    e                  19
    f                  19
    g                  18
    h                  18
    i                  18
    其实我就是想将就是想输出 连续出现的某个年龄的第一条记录而已。
    假设现在我想出输入年龄是18的。所以:
    前面有三个18岁的,所以输入a 18
    接着是三个19岁的,不输出。
    然后又是三个18岁的,所以输出 g 18
      

  3.   

    SQL> select * from t1;NAME              AGE
    ---------- ----------
    a                  18
    b                  18
    c                  19
    d                  19
    e                  18
    f                  186 rows selected.
    SQL> select name,age from
      2  (
      3  select name,age,
      4  decode(lag(age) over(order by name),null,age,lag(age) over(order by name))
    pre,
      5  row_number() over(order by name) rn
      6  from t1
      7  )
      8  where age<>pre
      9  or rn=1;NAME              AGE
    ---------- ----------
    a                  18
    c                  19
    e                  18
      

  4.   

    break on !我还是第一次见啊!
      

  5.   

    BREAK ON break_column 
    --屏蔽掉一个列中显示的相同的值 SQL> BREAK ON DEPTNO 
    SQL> SELECT DEPTNO, ENAME, SAL 
    FROM EMP 
    WHERE SAL < 2500 
    ORDER BY DEPTNO; 
    DEPTNO      ENAME         SAL 
    ---------- ----------- --------- 
    10           CLARK        2450 
    MILLER      1300 
    20            SMITH       800 
    ADAMS       1100
      

  6.   

    break on后,那一列怎么能恢复显示?
      

  7.   

    break on后,那一列怎么能恢复显示?
      

  8.   

    select name,age
    from(
      select t.*,lag(age)over(order by 1)l
      from student t)
    where (l<>age or l is null)and age=18其实这个需求比较不合常理。如果需要按name排序的话,将order by 1的1改成name
    用clear breaks
      

  9.   

    select * from student where age = "18" and row = 1