select sum(earningMoney) as 收入金额 ,sum(payoutMoney) as 支出金额 from AccountInfo as a where 1=a.bookId
为什么不能执行???????

解决方案 »

  1.   

    统计所有的可以不用group by的
    贴出错误代号一年就知道错在哪里
      

  2.   


    SELECT SUM (earningmoney) AS 收入金额, SUM (payoutmoney) AS 支出金额
      FROM accountinfo a
     WHERE 1 = a.bookid
      

  3.   

    from 表 后面不需要as 别名的
      

  4.   

    select sum(earningMoney) as 收入金额 ,sum(payoutMoney) as 支出金额 from AccountInfo as a where 1=a.bookId select sum(earningMoney) as 收入金额 ,sum(payoutMoney) as 支出金额 from AccountInfo  where 1=bookId 表名后面不要加as, 既然要给表起别名,为什么前面sum的时候,字段前面没有标注表名
      

  5.   


    select sum(earningMoney) as 收入金额 ,sum(payoutMoney) as 支出金额 from AccountInfo a where 1=a.bookId 把表后面的as去掉
      

  6.   

    select sum(earningMoney) as 收入金额 ,sum(payoutMoney) as 支出金额 from AccountInfo a where 1=a.bookId 
    不能执行会显示什么错误,并且要保证earningMoney和payoutMoney字段的值都为数值型,而且bookId的类型为数值型.
    语句写法本身是没有错误的