我只是想从两张表中,取得一张表的所有字段,另一张表,我想根据条件取得一个统计值,但是这个语句是有问题的,不知道如何修改能符合我的要求select t.id, t.title, t.createdate,count(s.*)
from callboard t,callboard_view s
where t.id=s.safeboardid and s.viewflag=0

解决方案 »

  1.   

    select t.id, t.title, t.createdate,count(s.safeboardid)
    from callboard t,callboard_view s 
    where t.id=s.safeboardid and s.viewflag=0
      

  2.   

    select t.id, t.title, t.createdate,count(s.safeboardid)--指定表PK就行
    from callboard t,callboard_view s 
    where t.id=s.safeboardid and s.viewflag=0
      

  3.   

    报ora-00937:非单组分组函数错误,其实开始我就用过这种形式,不行啊
      

  4.   

    select t.id, t.title, t.createdate,count(s.safeboardid)
    from callboard t,callboard_view s 
    where t.id=s.safeboardid and s.viewflag=0
    group by t.id, t.title, t.createdate
      

  5.   

    你这样写,肯定有问题,count(s.*)是一条数据,你可以把count(s.*)做为一个表来查select t.id, t.title, t.createdate,aa.count 
     from callboard t,callboard_view s,(select count(*) from callboard_view) aa
    where t.id=s.safeboardid and s.viewflag=0这个是随便写的,不知道能不能执行select * from clientcontent c,(select count(*) from userinfo) aa这条是在我数据库测试过的测试过的,
    clientcontent和userinfo是不同的表,查询结果,会在clientcontent后面加上一条数据(aa表的条数)