哪位高手知道怎么把一条select语句嵌套在 另一条select语句中的 from前面 当做字段来查询

解决方案 »

  1.   

    select 
          select from
    from 
      

  2.   


    select t.* from
    (select * from dbo.Customers)  t
      

  3.   


    select id,name=(select min(name) from tb) from tb 
      

  4.   

    select col1=(select colname from tb where ...),col2,col3 from tablename
      

  5.   

    SELECT 
    (SELECT A FROM B WHERE ID=1)
      

  6.   

    select id,name=(select min(name) from tb) from tb  用这种方式会提示未找到预期的from 关键字
      

  7.   

    select *,(select XX from tb where XX )
    from tb
      

  8.   

    ---要看你的数据,和具体要求
    if object_id('tb')is not null drop table tb
    go create table tb(id int,name int)
    insert tb select
    1,11 union all select
    1,12 union all select
    1,13 union all select
    2,14 union all select
    3,15 union all select
    4,16 union all select
    5,17select id,name=(select min(name) from tb) from tb 
    id          name
    ----------- -----------
    1           11
    1           11
    1           11
    2           11
    3           11
    4           11
    5           11(7 行受影响)
      

  9.   


    --sql 2005 
    with tablename
    as
    (select * from tb
    )
    select * from tablename
    where ...
      

  10.   

    SELECT 
    (SELECT A FROM B WHERE ID=1) 因为我语句中含有sum语句 所以还会提示非单组分组函数
      

  11.   

    select  sum(f.jine),(select zyh from zl where jzh='266165')    
      from ndns.zl a,mx f,ndns.test_1 g
     where  a.jzh = f.jzh 
          and f.xmdm = g.xmdm
    我用的是Oracle数据库,这条语句提示非单组分组函数
      

  12.   

    select  sum(f.jine)
      from ndns.zl a,mx f,ndns.test_1 g
     where  a.jzh = f.jzh 
    and a.jzh ='266165'
     and f.xmdm = g.xmdm
    sumsum(f.jine)
    1186.32(1行受影响)
    select zyh from zl where jzh='266165'
    zyh
    00113979(1行受影响)
     当两个语句合并的时候就报非单组分组函数