name     money
-----------------------------
a          100
b          30
c          50
d          120
e          80
查询条件 : 80正确的结果如下
name     money
-----------------------------
b          30
c          50
e          80

解决方案 »

  1.   

    select t.* from 表名 t where money<=80不知道是不是这个意思。
      

  2.   

    name money
    -----------------------------
    a 100
    b 30
    c 50
    e 80
    查询条件 : 110
      

  3.   

    with a as
     (
      select 'a' name, 100 money
        from dual
      union all
      select 'b', 30
        from dual
      union all
      select 'c', 50
        from dual
      union all
      select 'd', 120
        from dual
      union all
      select 'e', 80
        from dual  
      )
    select * from a where money<=&money;
      

  4.   

    5楼兄弟with a as 不明白是什么含义这语句如何使用。记录数是很多的。这样写可吗
      

  5.   

    select name , money from TABLE 
             where money <= 80 
             order by money desc;
    楼主是不是想排序啊……
      

  6.   

    select name , money from TABLE  
      where money <= 80  
      order by money desc;
      

  7.   

    with a as
     (
      select 'a' name, 100 money
      from dual
      union all
      select 'b', 30
      from dual
      union all
      select 'c', 50
      from dual
      union all
      select 'd', 120
      from dual
      union all
      select 'e', 80
      from dual   
      )
    select * from a where money<=&money;&自定义的变量
      

  8.   

    查询条件:80元存在 二条记录的金额相加=80,或三条记录金额相加=80 或 一条记录金额=80表中的记录是很多的。假设有1000条记录,5楼盘的解答如何使用,是在过程中写吗,还是直接SQL。因为我对 with a as 这里不明白。
      

  9.   

    select name,sum(money) sum from tab
    group by name having sum(money) < '&x';
      

  10.   

    with a as 是临时的结果集的命名
    你只关注他后面的select语句就行。
      

  11.   


    as()内的SQL如何才是动态的