急!把子查询的结果当作某个列来显示该怎样做?

解决方案 »

  1.   

    这样么:
    select b,(select a from tableA) a from tableB;
      

  2.   

    LS的写法是错的...如果子查询是列,用join.
      

  3.   

    不好意思,还有一问:a,b两表,a表(商品详情)的主键ddd(商品代码)是b表(销售情况)列ccc(商品代码)的外键,我想要的查询结果是显示对应a表ddd,b表ccc中销售时间最近的一条记录,这样写对吗?
    select a.ddd, (select max(b.销售时间) from b) from a,b where a.ddd=b.ccc请指教!!
      

  4.   

    如果子查询返回一行是可以的:
    select code,(select week from t2 where rownum<2) b from t1;
      

  5.   

    明显是错的。
    select a.id,max(b.value) from a,b
    where a.id=b.id
    group by a.id;
      

  6.   


    select a.ddd, max(b.销售时间)
      from a,b 
     where a.ddd=b.ccc
     group by a.ddd全部商品的最近一条记录.
      

  7.   

    对不起,我需要显示的还有a表中的其他字段,oracle提示非有效的group by 分组,怎么回事?
      

  8.   

    select a.id,a.others,max(b.value) from a,b 
    where a.id=b.id 
    group by a.id,a.others;
      

  9.   

       要顯示其他字段,也要把其他字段列到group by后面